mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-07-06 09:52:06 +02:00
Attempt auto-reconnect more than once
This commit is contained in:
+9
-5
@@ -312,9 +312,11 @@ class RadioManager:
|
|||||||
async def monitor_loop():
|
async def monitor_loop():
|
||||||
from app.websocket import broadcast_health
|
from app.websocket import broadcast_health
|
||||||
|
|
||||||
|
CHECK_INTERVAL_SECONDS = 5
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
await asyncio.sleep(5) # Check every 5 seconds
|
await asyncio.sleep(CHECK_INTERVAL_SECONDS)
|
||||||
|
|
||||||
current_connected = self.is_connected
|
current_connected = self.is_connected
|
||||||
|
|
||||||
@@ -325,10 +327,12 @@ class RadioManager:
|
|||||||
broadcast_health(False, self._connection_info)
|
broadcast_health(False, self._connection_info)
|
||||||
self._last_connected = False
|
self._last_connected = False
|
||||||
|
|
||||||
# Attempt reconnection
|
if not current_connected:
|
||||||
await asyncio.sleep(3) # Wait a bit before trying
|
# Attempt reconnection on every loop while disconnected
|
||||||
if await self.reconnect():
|
if not self.is_reconnecting:
|
||||||
await self.post_connect_setup()
|
if await self.reconnect():
|
||||||
|
await self.post_connect_setup()
|
||||||
|
self._last_connected = True
|
||||||
|
|
||||||
elif not self._last_connected and current_connected:
|
elif not self._last_connected and current_connected:
|
||||||
# Connection restored (might have reconnected automatically)
|
# Connection restored (might have reconnected automatically)
|
||||||
|
|||||||
Reference in New Issue
Block a user