From 00804a0f819faf67ea84fe88a045497f43445e4c Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Mon, 5 Feb 2024 16:53:16 -0700 Subject: [PATCH] Don't fail if message is received before websocket start (#9634) --- frigate/comms/ws.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frigate/comms/ws.py b/frigate/comms/ws.py index 98f24cf28..fccd8db5c 100644 --- a/frigate/comms/ws.py +++ b/frigate/comms/ws.py @@ -38,6 +38,7 @@ class WebSocketClient(Communicator): # type: ignore[misc] def __init__(self, config: FrigateConfig) -> None: self.config = config + self.websocket_server = None def subscribe(self, receiver: Callable) -> None: self._dispatcher = receiver @@ -98,6 +99,10 @@ class WebSocketClient(Communicator): # type: ignore[misc] logger.debug(f"payload for {topic} wasn't text. Skipping...") return + if self.websocket_server is None: + logger.debug("Skipping message, websocket not connected yet") + return + try: self.websocket_server.manager.broadcast(ws_message) except ConnectionResetError: