From 5f0eaf2e62b38f638528e0f1efa42214f3caed26 Mon Sep 17 00:00:00 2001 From: Jeroen Oudshoorn Date: Tue, 12 Sep 2023 13:20:59 +0200 Subject: [PATCH] Version 2.3.8 Signed-off-by: Jeroen Oudshoorn --- pwnagotchi/bettercap.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pwnagotchi/bettercap.py b/pwnagotchi/bettercap.py index d53dc45e..5fd84786 100644 --- a/pwnagotchi/bettercap.py +++ b/pwnagotchi/bettercap.py @@ -40,26 +40,26 @@ class Client(object): async def start_websocket(self, consumer): s = "%s/events" % self.websocket - while True: - try: - async with websockets.connect(s, ping_interval=60, ping_timeout=90) as ws: + async with websockets.connect(s, ping_interval=60, ping_timeout=90) as ws: + while True: + try: async for msg in ws: try: await consumer(msg) except Exception as ex: logging.debug("Error while parsing event (%s)", ex) - except websockets.ConnectionClosedError: - logging.error("Lost websocket connection. Reconnecting...") - continue - except websockets.WebSocketException as wex: - logging.error("Websocket exception (%s)", wex) - continue - except OSError as e: - logging.error("Websocket OSError exception (%s) with parameter %s", e, s) - continue - except Exception as e: - logging.error("Other exception (%s) with parameter %s", e, s) - continue + except websockets.ConnectionClosedError: + logging.error("Lost websocket connection. Reconnecting...") + continue + except websockets.WebSocketException as wex: + logging.error("Websocket exception (%s)", wex) + continue + except OSError as e: + logging.error("Websocket OSError exception (%s) with parameter %s", e, s) + continue + except Exception as e: + logging.error("Other exception (%s) with parameter %s", e, s) + continue def run(self, command, verbose_errors=True): for _ in range(0,2):