-
Notifications
You must be signed in to change notification settings - Fork 368
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
"ClosedChannelException while shutting down output" after using remote port forwarding tunnel #420
Comments
Can you provide simple code to reproduce this? |
Sort of, but it's not pretty. And I weren't able to reproduce it without also making the "http server" NOT close the socket after a read failure, which leads me to believe that the root issue is maybe something in our REST service not cleaning up keep-alive connections that are closed correctly. Anyway, here is the code that can reproduce this. It's not 100%, but often after a "http server: read failed, closing connection" you also get the "ClosedChannelException while shutting down output" INFO log entry. (I used slf4j-api 2.0.7 and logback-classic 1.4.8 to get logs and be able to control the root logger level): Server.java
Client.java
|
Thanks a lot for this code. I've rewritten this as a single JUnit test, (see PortForwardingHttpTest.java.txt) and I see the following things:
I suggest to fix (4) by checking in |
Fix Nio2Session.doCloseGracefully(): before calling AsynchronousSocketChannel.shutdownOutput(), check that the socket is still open, and if we get an IOException all the same, log it with TRACE level. See also comments in doShutdownOutputStream(). Bug: apache#420
Version
2.9.2
Bug description
We have two applications,
server
andclient
.server
has an Apache MINA SSHD server running andclient
connects to this using an Apache MINA SSHD client. Theclient
also sets up remort port forwarding tunnel, so thatserver
can connect to a REST service that is running onclient
via the ssh connection.After upgrading Apache MINA SSHD from version 1.4.0.0 to 2.9.2 on both applications we started to see an INFO log entry on
client
about "ClosedChannelException while shutting down output" when a connection over the remote port forwarding tunnel is closed. It happens almost every time a connection is closed, but not always.2023-09-27T10:23:01.257+02:00 INFO [131] org.apache.sshd.common.io.nio2.Nio2Session doCloseGracefully(Nio2Session[local=/[0:0:0:0:0:0:0:0]:52239, remote=localhost/127.0.0.1:8090]) ClosedChannelException while shutting down output: null
It seems to happen only when the connection is closed non-gracefully (RST instead of FIN). We are not sure why the connection is closed non-gracefully, it seems to be somehow related to
HttpURLConnection
and it's keep-alive functionality. It seems to close the connection non-gracefully if the connection has been idle for too long and is about to be removed from the keep-alive cache. This matches the timing (5 seconds, as that is the default keep-alive time) between connection creation and connection close.As this is an INFO log entry it might not be a problem at all, maybe this is fully expected when the connection over the tunnel is closed non-gracefully? But in that case, maybe it should not be on log level INFO?
Actual behavior
ClosedChannelException
INFO log entry when connection over remote port forwarding tunnel is closed non-gracefully.Expected behavior
Either no
ClosedChannelException
at all, or log level changed to avoid flooding the log when there are many connections created and closed over the tunnel.Relevant log output
Other information
No response
The text was updated successfully, but these errors were encountered: