Just for reference, my solution is: To keep the connection alive, and for both ends to realise that the connection has been dropped:
- setServerAliveInterval (in my case set to 30 seconds) - ClientAliveInterval in sshd config on the server (in my case set to 30 seconds) And then to reconnect on a dropped connection: - Using Timer to poll the Session object every 5 seconds, checking session.isConnected(), and to connect again. I used a new Session object, as re-using the same session gave some errors on malformed packets. Thanks! Michal. On 27 Feb 2012, at 20:55, Paul Ebermann wrote: > Michal Charemza skribis: >> Hi, >> >> I'm using this library in a project, with tunnelling, and I'm >> wondering if there is a mechanism that will auto-reconnect on a >> disconnect. Is this possible? I've searched for a configuration >> parameter, but not managed to find anything. Is there a way of using >> some sort of callback, or maybe a subclass of Session? I'm not really >> sure where to begin, so any pointers would be appreciated. >> >> There is no-user interaction on connection/re-connection, so there is >> no need for the system to prompt the user for a password/passphrase. > > The SSH protocol doesn't have a notion of a "session resumption" or similar, > so a reconnection would be a totally new connection, and also all the > channels which go over the encrypted session are thus broken, and need to be > restarted. > > You can manually "resume" a session by simply starting a new session with the > same parameters, and then starting these channels again. > > The problem would be how to know when the session is down ... I don't have a > solution for this, other than regularly polling, or having a channel with an > echo or similar. > > > PaĆlo ------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ _______________________________________________ JSch-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jsch-users
