kiranhegde264 / ganymed-ssh-2

Automatically exported from code.google.com/p/ganymed-ssh-2
Other
0 stars 0 forks source link

Thread hangs up on SocketRead0 #16

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Application initiates connection to server and performs some operations via 
SFTP.
2. Server goes to hardware reboot
3. Thread that expects answer hangs on SocketRead0

In thread dump:
"Thread-3" daemon prio=1 tid=0x46e11698 nid=0x6ee runnable 
[0xbadff000..0xbadff654]                                                        
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)at 
ch.ethz.ssh2.crypto.cipher.CipherInputStream.fill_buffer(CipherInputStream.java:
41)
at 
ch.ethz.ssh2.crypto.cipher.CipherInputStream.internal_read(CipherInputStream.jav
a:52)
at 
ch.ethz.ssh2.crypto.cipher.CipherInputStream.getBlock(CipherInputStream.java:79)
at ch.ethz.ssh2.crypto.cipher.CipherInputStream.read(CipherInputStream.java:108)
at 
ch.ethz.ssh2.transport.TransportConnection.receiveMessage(TransportConnection.ja
va:231)
at 
ch.ethz.ssh2.transport.TransportManager.receiveLoop(TransportManager.java:680)at
ch.ethz.ssh2.transport.TransportManager$1.run(TransportManager.java:468)at 
java.lang.Thread.run(Thread.java:595)

I've found connection estimation code:
    private void establishConnection(ProxyData proxyData, int connectTimeout) throws IOException
    {
        /* See the comment for createInetAddress() */

        if (proxyData == null)
        {
            InetAddress addr = createInetAddress(hostname);
            sock.connect(new InetSocketAddress(addr, port), connectTimeout);
            sock.setSoTimeout(0); // <----- !!!!
            return;
        }

        if (proxyData instanceof HTTPProxyData)
        {
            HTTPProxyData pd = (HTTPProxyData) proxyData;

            /* At the moment, we only support HTTP proxies */

            InetAddress addr = createInetAddress(pd.proxyHost);
            sock.connect(new InetSocketAddress(addr, pd.proxyPort), connectTimeout);
            sock.setSoTimeout(0); // <----- !!!!

It is a good idea to allow to tune SO_TIMEOUT for application that uses a 
connection.

Tried it with:
ganymed-ssh2-build251beta1.zip

You can also contact me for additional information.

Original issue reported on code.google.com by sadko_so...@rambler.ru on 22 Nov 2011 at 9:25

GoogleCodeExporter commented 8 years ago
we also need this fixed...

Original comment by s...@frequency.com on 24 May 2012 at 1:46

GoogleCodeExporter commented 8 years ago
I am also seeing the same issue. Any plan to fix this?

Original comment by vij...@gmail.com on 29 Jun 2012 at 10:44

GoogleCodeExporter commented 8 years ago
I also encountered this issue. How can I fix this? Will this be fixed? With 
this bug ganymed-ssh-2 is unusable.

Original comment by ltbluebe...@gmail.com on 12 Jun 2013 at 9:17

GoogleCodeExporter commented 8 years ago
Does anyone know if there has been any progress on this topic?  

I have noticed some similar behavior while using the GanyMed Library.  When 
executing similar tests to those described by the original poster: open 
connection on an unstable IP link, perform SFTP transactions, drop IP link to 
sshd on remote target, and at 
ch.ethz.ssh2.crypto.cipher.CipherInputStream.fill_buffer(CipherInputStream.java:
41)
I will intermittently receive a blocking read.  I can see this in the debugger 
as our software "hangs" and the NETSTAT command shows the connection as 
"ESTABLISHED" until manually terminated.  Ideally an exception or error of some 
sort would be thrown or returned. 

I am unsure if this is the exact same issue that is explained by the original 
poster, but I feel that it is similar enough that opening another issue isn't 
warranted.

Any insight into the status of this ticket is greatly appreciated!

Original comment by Bradley...@gmail.com on 23 Sep 2013 at 7:29

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
This has been fixed long ago in r10.

Original comment by dkocher@sudo.ch on 9 Apr 2014 at 7:44

GoogleCodeExporter commented 8 years ago
Hi.

dkocher:
I agree that r10 fixed the issue, but as far as I see this bug was 
re-introduced in r47 by the following code in TransportManager.java:

private static Socket establishConnection(...) {
Socket s = new Socket(); // (1) Creating new socket here, and thus earlier 
.setSoTimeout will not have effect.
// missing setSoTimeout here.
s.connect(new InetSocketAddress(addr, port), connectTimeout);
return s;
...
}

public void setSoTimeout(int timeout) throws IOException
    {
        sock.setSoTimeout(timeout);
    }
but sock.connect() is never called. Instead a new Socket is created in (1).

https://code.google.com/p/ganymed-ssh-2/source/diff?spec=svn47&r=47&format=side&
path=/trunk/src/main/java/ch/ethz/ssh2/transport/TransportManager.java

It would be great to see this issue re-opened and fixed.

Thanks
Regards

Original comment by refsdal....@gmail.com on 10 Apr 2014 at 7:00

GoogleCodeExporter commented 8 years ago

Original comment by dkocher@sudo.ch on 10 Apr 2014 at 12:02

GoogleCodeExporter commented 8 years ago
In r102.

Original comment by dkocher@sudo.ch on 10 Apr 2014 at 1:42