Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exception when close channel before SSL #12000

Closed
xingzhang8023 opened this issue Jan 13, 2022 · 1 comment · Fixed by #13099
Closed

exception when close channel before SSL #12000

xingzhang8023 opened this issue Jan 13, 2022 · 1 comment · Fixed by #13099
Milestone

Comments

@xingzhang8023
Copy link

Expected behavior

close channel no exception

Actual behavior

2022/01/13 17:56:07.897 [] [reactor-http-epoll-2] [WARN] i.n.h.s.ApplicationProtocolNegotiationHandler - [id: 0xa03cf599, L:/189.11.24.119:8443 ! R:/189.11.24.38:39277] Failed to select the application-level protocol:
java.nio.channels.ClosedChannelException: null
at io.netty.handler.ssl.SslHandler.channelInactive(SslHandler.java:1063) [netty-handler-4.1.72.Final.jar!/:4.1.72.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:262) [netty-transport-4.1.72.Final.jar!/:4.1.72.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:248) [netty-transport-4.1.72.Final.jar!/:4.1.72.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:241) [netty-transport-4.1.72.Final.jar!/:4.1.72.Final]
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1405) [netty-transport-4.1.72.Final.jar!/:4.1.72.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:262) [netty-transport-4.1.72.Final.jar!/:4.1.72.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:248) [netty-transport-4.1.72.Final.jar!/:4.1.72.Final]
at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:901) [netty-transport-4.1.72.Final.jar!/:4.1.72.Final]
at io.netty.channel.AbstractChannel$AbstractUnsafe$8.run(AbstractChannel.java:831)

Steps to reproduce

server is 189.11.24.119 8443
client is 189.11.24.38
The tcpdump packet capture result is as follows:
image

Minimal yet complete reproducer code (or URL to code)

NA

Netty version

4.1.72.Final

JVM version (e.g. java -version)

openjdk 11.0.8

OS version (e.g. uname -a)

linux x86

@hyperxpro
Copy link
Contributor

Related to spring-cloud/spring-cloud-gateway#2493

normanmaurer pushed a commit that referenced this issue Jan 24, 2023
…3099)

Motivation:
When a channel is closed during the SSL handshake then `java.nio.channels.ClosedChannelException` is thrown. This is correct when we see it from a low-level transport perspective but from a high-level, this error is not detailed enough to debug. And when we log `ClosedChannelException`, we get this line: `java.nio.channels.ClosedChannelException: null` in the stack trace. 

Modification:
To combat this, we should throw `StacklessSSLHandshakeException` with the message `"Connection closed while SSL/TLS handshake was in progress"` as suppressed with`ClosedChannelException`. This will explicitly declare that the handshake failed due to connection closure.

Result:
Fixes #12000

Co-authored-by: Idel Pivnitskiy <idel.pivnitskiy@apple.com>
normanmaurer pushed a commit that referenced this issue Jan 24, 2023
…3099)

Motivation:
When a channel is closed during the SSL handshake then `java.nio.channels.ClosedChannelException` is thrown. This is correct when we see it from a low-level transport perspective but from a high-level, this error is not detailed enough to debug. And when we log `ClosedChannelException`, we get this line: `java.nio.channels.ClosedChannelException: null` in the stack trace.

Modification:
To combat this, we should throw `StacklessSSLHandshakeException` with the message `"Connection closed while SSL/TLS handshake was in progress"` as suppressed with`ClosedChannelException`. This will explicitly declare that the handshake failed due to connection closure.

Result:
Fixes #12000

Co-authored-by: Idel Pivnitskiy <idel.pivnitskiy@apple.com>
@normanmaurer normanmaurer added this to the 4.1.88.Final milestone Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants