From 8b959c8be9639ac481be528ba8bc5a98f1cf51b2 Mon Sep 17 00:00:00 2001 From: OpenGnSys Support Team Date: Fri, 23 Apr 2021 00:33:08 +0200 Subject: #980 Broken TCP connection times out after 120 seconds through keepalive Enable TCP keepalive to detect if the ogServer is gone (hard reset). If no reply after 120 seconds, then release the connection to the server. --- src/ogClient.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/ogClient.py b/src/ogClient.py index 5b42858..2ab92d6 100644 --- a/src/ogClient.py +++ b/src/ogClient.py @@ -51,6 +51,11 @@ class ogClient: print('connecting...') self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.setblocking(0) + self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) + self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 60) + self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, 30) + self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, 4) + self.state = State.CONNECTING self.data = "" self.trailer = False -- cgit v1.2.3-18-g5258