From 09256ee9f38d69e494be9f8f795415735d731774 Mon Sep 17 00:00:00 2001 From: Wei Hong Date: Sun, 7 Jun 2026 00:12:48 +0800 Subject: [PATCH] Fix timeout error. --- client.py | 4 ++++ main.py | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/client.py b/client.py index 708a82b..b778d6c 100644 --- a/client.py +++ b/client.py @@ -762,6 +762,10 @@ class ServerJarClient(Application): context = self.get_tls_context() s = context.wrap_socket(raw, server_hostname=self.host) + # The connection timeout should not become an idle read timeout. + # Keep recv() blocking so quiet but healthy connections stay open. + s.settimeout(None) + with self.sock_lock: self.sock = s diff --git a/main.py b/main.py index 047378e..9542cb4 100644 --- a/main.py +++ b/main.py @@ -1008,6 +1008,16 @@ class SocketServer: except (ConnectionResetError, OSError): mgr.logger.info( "[SYS] Client disconnected. From {}:{}".format(self.client_address[0], self.client_address[1])) + except Exception as e: + mgr.logger.exception( + "[SYS] Client handler error. From %s:%s", + self.client_address[0], + self.client_address[1], + ) + try: + self.request.sendall(f"[SYS:ERR] Server handler error: {e}\n".encode("utf-8")) + except OSError: + pass finally: stop_evt.set() if log_q is not None: