Re: [JSch-users] Bug: ChannelDirectTCPIP fails if remote side sends EOF quickly
Status: Alpha
Brought to you by:
ymnk
From: Paul E. <Pau...@gm...> - 2011-05-24 18:50:43
|
(Atsuiko: Sorry for double sending, I first used the wrong sender address.) Paul Ebermann schrieb: > Atsuhiko Yamanaka schrieb: >> Hi, >> >> Sorry for my delay of reply, > > No problem, I have enough other things to do in the meantime. > > (And also, Axis seems to not provide any way to set a specific > SocketFactory object, only a SocketFactory class name, thus I'll > have to use normal port forwarding for my project.) > >> +-From: Paul Ebermann <Pau...@gm...> -- >> |_Date: Fri, 20 May 2011 03:24:27 +0200 _______ >> | >> |I tried to open a direct-tcpip channel to some TCP server which replies >> |with a message and immediately closes the connection. (See [0] for background.) >> ... >> |As we can see, the remote host sends an SSH_MSG_CHANNEL_EOF before our channel's >> |connect() method had the chance to even see that the connection is open, and thus >> |it throws an exception instead of simply returning. >> >> You are right. It must be a bug. Could you try the following? >> http://www.jcraft.com/jsch/jsch-0.1.45-rc3.zip > > Now the StreamForwarding example doesn't do anything after connecting > (independently of whether the server sends something, ends the stream > or not). An addition: The only output is this line: System.{in,out} will be forwarded to localhost:2006. Now I have even more strange results. Your plain sources compiled and executed with java version "1.4.2_04" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode) work without any problems, while the same class files running with java version "1.6.0_20" OpenJDK Runtime Environment (IcedTea6 1.9.7) (suse-1.2.1-x86_64) OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode) give the hanging described above. (The main thread finishes, but there is no output at all.) The "Connect thread 141.20.23.223 session" stays in java.lang.Thread.State: RUNNABLE at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:146) at com.jcraft.jsch.IO.getByte(IO.java:82) at com.jcraft.jsch.Session.read(Session.java:837) at com.jcraft.jsch.Session.run(Session.java:1259) at java.lang.Thread.run(Thread.java:636) On the server the TCP connection to 2006 is already closed, nothing to see there (but the SSH connection is still open, of course). The same occurs with this runtime: java version "1.5.0_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08) Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode) Now, with my current master branch (just pushed to github), it works even on 1.6.0_20, with activated logging. The differences (apart from lots of addes (documentation) comments) are only logging output in ChannelDirectTCPIP and Session (I'm just looking at the diff). Then, using the `better-examples` branch, I sometimes get the output, but still the exception, while at other times I'll get no output (only the exception (like the log in the last message) - just now in two successing runs of the same program. (Both with activated logging.) If I port only the logging changes to your RC version (see branch directtcpip-bug), the output shows nothing without logging, and with logging sometimes the data, sometimes not. It never shows the exception. (The difference on showing the output or not is whether the SSH_MSG_CHANNEL_DATA comes before "finished waiting" (it shows the output) or after it (it doesn't show).) Could it be that there is a timing problem (i.e. some race condition)? I didn't yet look thouroughly at your new implementation of ChannelDirectTCPIP.connect, only superficialy to add my logging again. Paŭlo |