Use keepalive and reduce ping interval

Some networks will kill connections sooner than 60s, especially if they are not using keepalive. This fix should reduce the random disconnects some players experience
This commit is contained in:
fourbites
2026-03-16 14:16:21 +01:00
parent b6a687d2fa
commit 2a8db32013
2 changed files with 2 additions and 1 deletions
@@ -660,6 +660,7 @@ public class BlockingCommunicator extends Communicator
InetAddress host = InetAddress.getByName(_client.getHostname()); InetAddress host = InetAddress.getByName(_client.getHostname());
openChannel(host); openChannel(host);
_channel.configureBlocking(true); _channel.configureBlocking(true);
_channel.socket().setKeepAlive(true);
// our messages are framed (preceded by their length), so we use these helper streams // our messages are framed (preceded by their length), so we use these helper streams
// to manage the framing // to manage the framing
@@ -17,7 +17,7 @@ public class PingRequest extends UpstreamMessage
{ {
/** The number of milliseconds of idle upstream that are allowed to elapse before the client /** The number of milliseconds of idle upstream that are allowed to elapse before the client
* sends a ping message to the server to let it know that we're still alive. */ * sends a ping message to the server to let it know that we're still alive. */
public static final long PING_INTERVAL = 60 * 1000L; public static final long PING_INTERVAL = 30 * 1000L;
/** /**
* Zero argument constructor used when unserializing an instance. * Zero argument constructor used when unserializing an instance.