From 7ea2311b175bc3856c586284e8cf6c3830a9b27b Mon Sep 17 00:00:00 2001 From: TheTechromancer Date: Mon, 25 Sep 2023 12:04:19 -0400 Subject: [PATCH] fixed unhandled websockets error in agent --- bbot/agent/agent.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bbot/agent/agent.py b/bbot/agent/agent.py index f30fb94d15..09eff2a03b 100644 --- a/bbot/agent/agent.py +++ b/bbot/agent/agent.py @@ -51,7 +51,14 @@ async def ws(self, rebuild=False): verbs = ("Rebuilding", "Rebuilt") url = f"{self.url}/control/" log.debug(f"{verbs[0]} websocket connection to {url}") - self._ws = await websockets.connect(url, **kwargs) + while 1: + try: + self._ws = await websockets.connect(url, **kwargs) + break + except Exception as e: + log.error(f'Failed to establish websockets connection to URL "{url}": {e}') + log.trace(traceback.format_exc()) + await asyncio.sleep(1) log.debug(f"{verbs[1]} websocket connection to {url}") return self._ws