Skip to content

Commit

Permalink
Don't fail if message is received before websocket start (#9634)
Browse files Browse the repository at this point in the history
  • Loading branch information
NickM-27 committed Feb 5, 2024
1 parent a33f2f1 commit 00804a0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions frigate/comms/ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -98,6 +99,10 @@ def publish(self, topic: str, payload: str, _: bool) -> None:
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:
Expand Down

0 comments on commit 00804a0

Please sign in to comment.