[
https://issues.apache.org/jira/browse/SSHD-902?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16778831#comment-16778831
]
Yumin Sang commented on SSHD-902:
---------------------------------
I think IO should be closed. In code of JSch, IO is closed. In SSHD, EOF
process goes to org.apache.sshd.common.channel.AbstractChannel#handleEof, and
notifyStateChanged("SSH_MSG_CHANNEL_EOF") is done. I didn't find operations
like IO closing. But I'm not familiar with the mechanism, my watching and
thinking may be wrong. I'm not sure that EOF handling is the root cause of the
"hang" depicted in reproduce steps either. So the title of this issue may be
not proper.
> Local port forwarding: EOF is not handled properly
> --------------------------------------------------
>
> Key: SSHD-902
> URL: https://issues.apache.org/jira/browse/SSHD-902
> Project: MINA SSHD
> Issue Type: Bug
> Affects Versions: 2.1.0
> Environment: 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
> Reporter: Yumin Sang
> Priority: Critical
> Attachments: AbstractServerCloseTestSupport.java,
> ApacheServerApacheClientTest.java, packets.PNG
>
>
> 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?|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)
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)