diff options
author | OpenGnSys Support Team <soporte-og@soleta.eu> | 2021-04-23 00:33:08 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2021-04-23 00:34:39 +0200 |
commit | 8b959c8be9639ac481be528ba8bc5a98f1cf51b2 (patch) | |
tree | e371b2620b7c952dc824862ff5eb418afc4440aa | |
parent | baa03debd7b44123dbb9dc7bec178c917d3498cd (diff) |
#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.
-rw-r--r-- | src/ogClient.py | 5 |
1 files changed, 5 insertions, 0 deletions
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 |