fix: 重连时间设置更小

This commit is contained in:
2026-07-31 14:09:11 +08:00
parent 3fcd38f417
commit f0df9ad915
2 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -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 建连耗时采样次数,取中位数
+6 -6
View File
@@ -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主循环的顶层异常捕获,防止线程静默退出