Menu

#43 Session stuck in write(Packet packet)

open
nobody
None
5
2014-08-21
2010-02-26
Anonymous
No

User application:
The application will use both sftp and scp to transfer files. In one scenario the session will stuck and never recovers.

Steps to reproduce:

1. User thread create and connect a Session., then open and connect a ChannelSftp channel.
2. User thread will use scp to transfer a list of small files.
3. User thread then try to open and connect a ChannelExec. Now it's in the middle of connect()
-- session.rekey();
-- channelScp = (ChannelExec)session.openChannel("exec");
-- channelScp.connect(30000);

Stack trace of channelScp.connect(30000):
java.lang.Thread.sleep(Native Method)
com.jcraft.jsch.Session.write(Session.java:1161) // command = 90
com.jcraft.jsch.Channel.connect(Channel.java:168)

4. Disconnect the network access of the sshd server (I am using Solaris sshd). Then JSch thread tries to disconnect the session
Stack trace:
java.lang.Thread.sleep(Native Method)
com.jcraft.jsch.Session.write(Session.java:1161) // command = Session.SSH_MSG_CHANNEL_CLOSE
com.jcraft.jsch.Channel.close(Channel.java:483)
com.jcraft.jsch.Channel.disconnect(Channel.java:525)
com.jcraft.jsch.ChannelSftp.disconnect(ChannelSftp.java:2301)
com.jcraft.jsch.Channel.disconnect(Channel.java:509)
com.jcraft.jsch.Session.disconnect(Session.java:1514)
com.jcraft.jsch.Session.run(Session.java:1482)
java.lang.Thread.run(Thread.java:619)

5. Both threads are stuck in com.jcraft.jsch.Session.write(Session.java:1161) in the while (in_key) loop, and never recovers.

Discussion


Log in to post a comment.