Sometimes the connection freezes and becomes unresponsive. This usually occurs after a period of idleness on a low-traffic connection. The TCP network layer simply times-out, but the app won't discover it until it attempts to send something over the connection. If it's a bot, it will simply hang waiting for next input from the server. (Note: I'm not talking about idle-logout here... this is something else.)
The fix for this is to have the TCP layer send periodic keep-alives. This can be done using:
socket.setKeepAlive(true);
This won't impact idle-logout. It's strictly at the network level and avoids a TCP timeout on low-traffic connections.
I've attached a modified version of Connection.java which sets this option, to ensure the TCP layer never goes stale. It's good for both Bots and regular users.
Connection.java...
protected Socket connectImpl(String hostname, int port) throws IOException{
Socket s = new Socket(hostname, port);
s.setKeepAlive(true);
return s;
}
Updated Connection.java which sets the keep-alive socket option.