Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the default timeout for Session and Channel in JSch library in java

Does anyone know the default timeout for Session and Channel.

session.connect();
channel.connect();

I am going through the document but it doesn't explicitly say what is the default timeout ?

like image 517
Adon Smith Avatar asked Mar 18 '23 07:03

Adon Smith


1 Answers

For the Channel, the default timeout seems to be 20 seconds.

See the implementation of the Channel.sendChannelOpen().

The timeout here defines, how long will the connect() wait for a response to open channel request. I'd say that the name of the method is confusing, it should be open(). You are not connecting anywhere (the session is already open).


For the Session, the default timeout is set using the setTimeout() method. If not set, the default default is 0, what means "infinite". Though there's always some last resort timeout on an OS-level.

The timeout here defines:

  • How long will the connect() wait for the socket to open.
    Though this defines an upper limit only, to define a lower limit, see JSch session timeout limit.
  • Timeout for all future "reads" from the socket. See the Socket.SetSoTimeout
  • It also affects a connection to a proxy, if there's any.
like image 181
Martin Prikryl Avatar answered Apr 13 '23 20:04

Martin Prikryl