From f0df9ad9157efcac2b67e8e75445d7c3db55fa3d Mon Sep 17 00:00:00 2001 From: linyimin <18316471919@139.com> Date: Fri, 31 Jul 2026 14:09:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=87=8D=E8=BF=9E=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=9B=B4=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 2 +- network.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config.py b/config.py index b39d257..870897a 100644 --- a/config.py +++ b/config.py @@ -24,7 +24,7 @@ TRIANGLE_DETECT_SCALE = 0.4 # SERVER_IP = "stcp.shelingxingqiu.com" SERVER_IP = "www.shelingxingqiu.com" SERVER_PORT = 50005 -HEARTBEAT_INTERVAL = 15 # 心跳间隔(秒) +HEARTBEAT_INTERVAL = 5 # 心跳间隔(秒) # WiFi 质量评估(开机先尝试 WiFi;质量差且 4G 可用则切到 4G,本次上电直至关机锁定 4G) WIFI_QUALITY_RTT_SAMPLES = 3 # 到业务服务器 TCP 建连耗时采样次数,取中位数 diff --git a/network.py b/network.py index e5beefb..ebda78a 100644 --- a/network.py +++ b/network.py @@ -1832,7 +1832,7 @@ class NetworkManager: continue if not self.connect_server(): - time.sleep_ms(5000) + time.sleep_ms(1000) continue # 发送登录包 @@ -1853,7 +1853,7 @@ class NetworkManager: self.disconnect_server() except: pass - time.sleep_ms(2000) + time.sleep_ms(500) continue self.logger.info("➡️ 登录包已发送,等待确认...") @@ -2342,8 +2342,8 @@ class NetworkManager: pass break else: - # 不立即断开,让下一轮心跳再试;同时缩短一点等待,提升恢复速度 - time.sleep_ms(200) + # 不立即断开,让下一轮心跳再试 + time.sleep_ms(50) continue else: send_hartbeat_fail_count = 0 @@ -2373,8 +2373,8 @@ class NetworkManager: self._send_event.clear() self._tcp_connected = False - self.logger.error("连接异常,2秒后重连...") - time.sleep_ms(200) + self.logger.error("连接异常,50ms后重连...") + time.sleep_ms(50) except Exception as e: # TCP主循环的顶层异常捕获,防止线程静默退出