jetty / jetty.project

Eclipse Jetty® - Web Container & Clients - supports HTTP/2, HTTP/1.1, HTTP/1.0, websocket, servlets, and more
https://eclipse.dev/jetty
Other
3.84k stars 1.91k forks source link

Investigate why Windows returns ClosedChannelException in Http2Client instead of ConnectException #6660

Open joakime opened 3 years ago

joakime commented 3 years ago

Jetty version(s) Jetty 10.0.x

Java version/vendor (use: java -version) Java 11.0.12

OS type/version Windows 10

Description

When an attempt is made to connect to a remote that isn't listening, Windows will return a ClosedChannelException instead of the expected ConnectException.

This is the following stacktrace seen in WebSocketOverHTTP2Test.testWebSocketConnectPortDoesNotExist

2021-08-23 16:52:39.414:INFO :oejs.AbstractConnector:main: Started ServerConnector@4b68d2a6{SSL, (ssl, alpn, http/1.1, h2)}{0.0.0.0:63433}
2021-08-23 16:52:39.414:INFO :oejs.Server:main: Started Server@4fdf83bb{STARTING}[10.0.7-SNAPSHOT,sto=0] @15090ms
2021-08-23 16:52:39.415:WARN :oejusS.config:main: Trusting all certificates configured for Client@4632d697[provider=null,keyStore=null,trustStore=null]
2021-08-23 16:52:39.415:WARN :oejusS.config:main: No Client EndPointIdentificationAlgorithm configured for Client@4632d697[provider=null,keyStore=null,trustStore=null]
java.nio.channels.ClosedChannelException
    at org.eclipse.jetty.http2.HTTP2Session$StreamsState.onShutdown(HTTP2Session.java:1812)
    at org.eclipse.jetty.http2.HTTP2Session.onShutdown(HTTP2Session.java:985)
    at org.eclipse.jetty.http2.HTTP2Connection$HTTP2Producer.produce(HTTP2Connection.java:313)
    at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.produceTask(AdaptiveExecutionStrategy.java:446)
    at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:239)
    at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.produce(AdaptiveExecutionStrategy.java:190)
    at org.eclipse.jetty.http2.HTTP2Connection.produce(HTTP2Connection.java:208)
    at org.eclipse.jetty.http2.HTTP2Connection.onFillable(HTTP2Connection.java:155)
    at org.eclipse.jetty.http2.HTTP2Connection$FillableCallback.succeeded(HTTP2Connection.java:378)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
    at org.eclipse.jetty.io.SocketChannelEndPoint$1.run(SocketChannelEndPoint.java:101)
    at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:412)
    at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:381)
    at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:268)
    at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.produce(AdaptiveExecutionStrategy.java:190)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:894)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1038)
    at java.base/java.lang.Thread.run(Thread.java:829)
joakime commented 3 years ago

I just noticed a test failure on ConnectorTimeoutTest that seems to overlap with this issue.

2021-08-25 06:24:27.386:INFO :oejs.Server:main: jetty-10.0.7-SNAPSHOT; built: 2021-08-25T11:10:56.055Z; git: cb3bd92fe3a3dabf34311d9684d09408136dfe7e; jvm 11.0.12+7
2021-08-25 06:24:27.479:INFO :oejus.SslContextFactory:main: x509=X509@c63a15f(mykey,h=[localhost],a=[/127.0.0.1, /0:0:0:0:0:0:0:1],w=[]) for Server@1f49b38a[provider=null,keyStore=file:///C:/code/jetty.project/jetty-server/src/test/resources/keystore.p12,trustStore=null]
2021-08-25 06:24:27.515:INFO :oejs.AbstractConnector:main: Started ServerConnector@5f36046{SSL, (ssl, http/1.1)}{0.0.0.0:49818}
2021-08-25 06:24:27.515:INFO :oejs.Server:main: Started Server@7812acea{STARTING}[10.0.7-SNAPSHOT,sto=0] @512288ms
2021-08-25 06:24:29.980:WARN :oejs.ConnectorTimeoutTest:junit-timeout-thread-20: Unable to read stream
javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake
        at java.base/sun.security.ssl.SSLSocketImpl.handleEOF(SSLSocketImpl.java:1616)
        at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1434)
        at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1336)
        at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:450)
        at java.base/sun.security.ssl.SSLSocketImpl.ensureNegotiated(SSLSocketImpl.java:841)
        at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:932)
        at java.base/sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
        at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
        at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
        at java.base/java.io.InputStreamReader.read(InputStreamReader.java:181)
        at org.eclipse.jetty.util@10.0.7-SNAPSHOT/org.eclipse.jetty.util.IO.copy(IO.java:221)
        at org.eclipse.jetty.util@10.0.7-SNAPSHOT/org.eclipse.jetty.util.IO.copy(IO.java:129)
        at org.eclipse.jetty.util@10.0.7-SNAPSHOT/org.eclipse.jetty.util.IO.toString(IO.java:332)
        at org.eclipse.jetty.util@10.0.7-SNAPSHOT/org.eclipse.jetty.util.IO.toString(IO.java:301)
        at org.eclipse.jetty.server@10.0.7-SNAPSHOT/org.eclipse.jetty.server.ConnectorTimeoutTest.lambda$testMaxIdleNothingSent$4(ConnectorTimeoutTest.java:534)
        at org.junit.jupiter.api.AssertTimeout.lambda$assertTimeoutPreemptively$2(AssertTimeout.java:102)
        at org.junit.jupiter.api.AssertTimeout.lambda$assertTimeoutPreemptively$4(AssertTimeout.java:138)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by:
java.io.EOFException: SSL peer shut down incorrectly
        at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:483)
        at java.base/sun.security.ssl.SSLSocketInputRecord.readHeader(SSLSocketInputRecord.java:472)
        at java.base/sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:160)
        at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:111)
        at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1426)
        at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1336)
        at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:450)
        at java.base/sun.security.ssl.SSLSocketImpl.ensureNegotiated(SSLSocketImpl.java:841)
        at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:932)
        at java.base/sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
        at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
        at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
        at java.base/java.io.InputStreamReader.read(InputStreamReader.java:181)
        at org.eclipse.jetty.util@10.0.7-SNAPSHOT/org.eclipse.jetty.util.IO.copy(IO.java:221)
        at org.eclipse.jetty.util@10.0.7-SNAPSHOT/org.eclipse.jetty.util.IO.copy(IO.java:129)
        at org.eclipse.jetty.util@10.0.7-SNAPSHOT/org.eclipse.jetty.util.IO.toString(IO.java:332)
        at org.eclipse.jetty.util@10.0.7-SNAPSHOT/org.eclipse.jetty.util.IO.toString(IO.java:301)
        at org.eclipse.jetty.server@10.0.7-SNAPSHOT/org.eclipse.jetty.server.ConnectorTimeoutTest.lambda$testMaxIdleNothingSent$4(ConnectorTimeoutTest.java:534)
        at org.junit.jupiter.api.AssertTimeout.lambda$assertTimeoutPreemptively$2(AssertTimeout.java:102)
        at org.junit.jupiter.api.AssertTimeout.lambda$assertTimeoutPreemptively$4(AssertTimeout.java:138)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)
2021-08-25 06:24:29.980:INFO :oejs.Server:main: Stopped Server@7812acea{STOPPING}[10.0.7-SNAPSHOT,sto=0]
2021-08-25 06:24:29.980:INFO :oejs.AbstractConnector:main: Stopped ServerConnector@5f36046{SSL, (ssl, http/1.1)}{0.0.0.0:0}
github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 2 years ago

This issue has been closed due to it having no activity.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 4 days ago

This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.