Prasanna Kumari - 2012-01-23

2012-01-18 23:14:17 PST
Invocation of jsch api from a windows to an embedded Linux machine is hanging .

There is an embedded Linux box to which a connection attempt is made using the "jsch" api. It is noticed that the connection hangs. One more observation is that this is not happening when the jsch api is invoked from another Linux machine. This is seen only when the api invocation happens from a windows box.

Here is the exact sequence of steps that we follow for opening a jsch connection

1. Get the session object.
2. Obtain the channel object.
3. Invoke the channel's getInputStream and getExtInputStream methods.
4. Read the contents in these streams using a BufferedReader.

We noticed that the hang is happening when we iterate to read the contents of the stream using readLine() method. Given below is the dump of the thread that is hanging -

"Thread-13" prio=6 tid=0x55a5d000 nid=0x18b8 in Object.wait()
  java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x223d1408> (a com.jcraft.jsch.Channel$MyPipedInputStream)
    at java.io.PipedInputStream.read(PipedInputStream.java:310)
    - locked <0x223d1408> (a com.jcraft.jsch.Channel$MyPipedInputStream)
    at java.io.PipedInputStream.read(PipedInputStream.java:361)
    - locked <0x223d1408> (a com.jcraft.jsch.Channel$MyPipedInputStream)
    at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
    at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
    - locked <0x223d74a8> (a java.io.InputStreamReader)
    at java.io.InputStreamReader.read(InputStreamReader.java:167)
    at java.io.BufferedReader.fill(BufferedReader.java:136)
   at java.io.BufferedReader.readLine(BufferedReader.java:299)
    - locked <0x223d74a8> (a java.io.InputStreamReader)
    at java.io.BufferedReader.readLine(BufferedReader.java:362

Can you please let me know the probable cause of the issue?