#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.
more_events
OpenGnSys Support Team 2021-04-23 00:33:08 +02:00
parent baa03debd7
commit 8b959c8be9
1 changed files with 5 additions and 0 deletions

View File

@ -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