Details
-
Bug
-
Status: Resolved
-
Critical
-
Resolution: Fixed
-
2.1.0
-
None
-
OS: both Windows 10 and Red Hat Enterprise Linux Server release 7.4 (Maipo) Linux 4.1.12-124.19.2.el7uek.x86_64 x86_64
JDK: 1.8.0_201
SSHD: 2.1.0
Description
Set remote port to a real listening port but is not for DB connection. Start a local port forwarding. Try getting a connection through the established SSH tunnel. This operation is expected to be finished with some error, but it hangs.
Reproduce steps:
- prepare a Linux server and find a listening port, such as 2049, which is not of DB listener.
- get attached demo code: ApacheServerApacheClientTest.java and AbstractServerCloseTestSupport.java. They are modified from the ones in mina-sshd-2.1.0\sshd-core\src\test\java\org\apache\sshd\common\forward. Please replace the corresponding ones.
- download ojdbc8.jar from https://www.oracle.com/technetwork/database/features/jdbc/jdbc-ucp-122-3110062.html? and add it to classpath.
- set up a local port forwarding tunnel by Putty or other tools. Set the forwarded local port to 37777, remote server/port to the server/port in step 1.
- run ApacheServerApacheClientTest.java. It finishes with error like java.io.IOException: Got minus one from a read call. This is expected behavior.
- change org.apache.sshd.common.forward.AbstractServerCloseTestSupport#testLocalPortForwardOneBuffer: uncomment line "int serverPort = startLocalPF();" and comment line "int serverPort = 37777;"
- change org.apache.sshd.common.forward.ApacheServerApacheClientTest#createClient, set username, host and password to the ones in step 1.
- run ApacheServerApacheClientTest.java again and it hangs.
By capturing loopback packets, it can be found the interactions are same, but SSHD make different process from what Putty does. In attached snapshot, the "nfs" is of port 2049.
Did a bit digging up, and it seems that EOF is not handled properly. Here is a call stack:
handleEof:873, AbstractChannel (org.apache.sshd.common.channel)
channelEof:498, AbstractConnectionService (org.apache.sshd.common.session.helpers)
process:357, AbstractConnectionService (org.apache.sshd.common.session.helpers)
doHandleMessage:626, AbstractSession (org.apache.sshd.common.session.helpers)
handleMessage:559, AbstractSession (org.apache.sshd.common.session.helpers)
decode:1542, AbstractSession (org.apache.sshd.common.session.helpers)
messageReceived:520, AbstractSession (org.apache.sshd.common.session.helpers)
messageReceived:63, AbstractSessionIoHandler (org.apache.sshd.common.session.helpers)
handleReadCycleCompletion:339, Nio2Session (org.apache.sshd.common.io.nio2)
onCompleted:318, Nio2Session$1 (org.apache.sshd.common.io.nio2)
onCompleted:315, Nio2Session$1 (org.apache.sshd.common.io.nio2)
lambda$completed$0:38, Nio2CompletionHandler (org.apache.sshd.common.io.nio2)
run:-1, 391147216 (org.apache.sshd.common.io.nio2.Nio2CompletionHandler$$Lambda$73)
doPrivileged:-1, AccessController (java.security)
completed:37, Nio2CompletionHandler (org.apache.sshd.common.io.nio2)
invokeUnchecked:126, Invoker (sun.nio.ch)
run:218, Invoker$2 (sun.nio.ch)
run:112, AsynchronousChannelGroupImpl$1 (sun.nio.ch)
runWorker:1149, ThreadPoolExecutor (java.util.concurrent)
run:624, ThreadPoolExecutor$Worker (java.util.concurrent)
run:748, Thread (java.lang)
Attachments
Attachments
Issue Links
- is related to
-
SSHD-964 SSH_MSG_CHANNEL_EOF never sent or received for local and remote port forwarding
- Resolved
- links to