The 1.7 Maverick Legacy Client API has an in-built mechanism for handling socket timeouts. You should configure the Ssh2Context accordingly with the values described below. If you are setting a timeout on the socket directly it will get overridden by our API settings.
((Ssh2Context)con.getContext(2)).setSocketTimeout(30000);
((Ssh2Context)con.getContext(2)).setIdleConnectionTimeoutSeconds(120);
The socket timeout configured on the Ssh2Context is used to configure the socket. This value should be less than the idle connection timeout, as timeout events are monitored and used to calculate the idle time of the connection. Leaving the default socket timeout is recommended, only changing the idle timeout value to suit your requirements.
You can also use the setSendIgnorePacketOnIdle property to force the transport to send a special packet to check the status of the connection. This will be sent every time the socket times out.