summaryrefslogtreecommitdiffstats
path: root/src/ogClient.py
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2021-04-23 00:33:08 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2021-04-23 00:34:39 +0200
commit8b959c8be9639ac481be528ba8bc5a98f1cf51b2 (patch)
treee371b2620b7c952dc824862ff5eb418afc4440aa /src/ogClient.py
parentbaa03debd7b44123dbb9dc7bec178c917d3498cd (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.
Diffstat (limited to 'src/ogClient.py')
-rw-r--r--src/ogClient.py5
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