Open GoogleCodeExporter opened 8 years ago
Is this likely to be fixed by the r=157 change which removes the idle flag from
TransportManager? [Before this revision, this flag was inspected following a
socket read timeout and the connection closed if not idle (e.g. a command has
been executed in the mean time).]
If so when is the next release build expected?
Original comment by jeremy.s...@cyclone-technology.com
on 2 Sep 2014 at 2:12
Just grabbed the latest from trunk to give it a go. It looks like it now closes
the connection for every read timeout. It was worth a try.
Original comment by jeremy.s...@cyclone-technology.com
on 2 Sep 2014 at 2:29
To cut a long story short I'm experiencing the same thing too in svn rev 161.
I've got an older jar called "ganymed-ssh2-build251beta1.jar" which does not
exhibit this problem. (I don't have the source for this)
Quite a lot of refactoring has gone on, but I think snv rev 10
"Patchset from Cyberduck. * Option in constructor to pass custom
identification * No infite timeout for socket connect * Idle detection for
read timeouts" provides a clue.
This change added setting the timeout on the underlying socket during the
connect - tm.setSoTimeout(connectTimeout);
but does not reset it back to 0 (infinite timeout) so this connection timeout
will be used on all subseqent reads.
I can't see any public access to the 'tm' member, so there doesn't appear to be
a way to access the Transport manager directly or the socket to set the options
back in application code - so if this is a problem for anyone then they'll
probably have to build the source themselves.
Original comment by goo...@oweno.info
on 19 Nov 2014 at 1:23
[deleted comment]
The attached patch fixed my issue.
Since I didn't know how to test the original problem I left the setting of the
timeout on the underlying socket during connect() in place and just re-set it
to zero at the end of connect()
It might be possible to remove both calls to setSoTimeout since all the calls
to Socket.Connect have a timeout on - I guess it does some reading establishing
the SSH connection onto of the TCP connection and the timeout on the read might
be to allow for the rare case where a TCP connect happens but then there isn't
anything on the other end of the socket to talk to.
Original comment by goo...@oweno.info
on 19 Nov 2014 at 3:04
Attachments:
Socket#setSoTimeout and Socket#connect should have different timeout values
I am having the same problem with rev161:
In ch.ethz.ssh2.Connection the connectTimeout is used for Socket#connect and
for Socket#setSoTimeout:
public synchronized ConnectionInfo connect(ServerHostKeyVerifier verifier, int connectTimeout, int kexTimeout)
throws IOException {
[...]
tm.setSoTimeout(connectTimeout);
[...]
tm.connect(hostname, port, softwareversion, cryptoWishList, verifier, dhgexpara, connectTimeout,
getOrCreateSecureRND());
[...]
}
In ch.ethz.ssh2.transport.ClientTransportManager connect is done via:
protected void connect(String hostname, int port, int connectTimeout)
throws IOException {
sock.connect(new InetSocketAddress(hostname, port), connectTimeout);
}
I have following use case, we are using ganymed to also connect to windows MKS
SSHD. The MKS SSHD tends to hang in High-Load Scenarios on our ESX-Servers.
Therefore, the initial connect Socket#connect should timeout after 60 sec (in
order to retry). However after a connection has been established it is normal
and no failure that read-calls block for more than 60 sec, since there is
nothing to read for a longer time. The problem is that due to
Socket#setSoTimeout gets the very same value as Socket#connect I can't handle
this situation. A third timeout parameter would solve the problem. Something
like:
public synchronized ConnectionInfo connect(ServerHostKeyVerifier verifier, int connectTimeout, int kexTimeout, int soTimeout)
throws IOException {
[...]
tm.setSoTimeout(connectTimeout);
[...]
tm.connect(hostname, port, softwareversion, cryptoWishList, verifier, dhgexpara, connectTimeout,
getOrCreateSecureRND());
[...]
tm.setSoTimeout(soTimeout)
}
Thanks & Best regards
Stefan
Original comment by stefan...@gmail.com
on 20 Jan 2015 at 5:53
The solution in comment #5 is better than introducing an extra parameter
soTimeout. Since there is the very useful Session#waitForCondition Method a
soTimeout would be no addition for functionality but would have the potential
to confuse things.
Original comment by stefan...@gmail.com
on 20 Jan 2015 at 6:25
Original issue reported on code.google.com by
francesc...@gmail.com
on 23 Aug 2014 at 5:56