From 5c71715e0ab286c75f8d43c14e5edfec93444dbd Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Thu, 2 Nov 2023 08:37:36 -0500 Subject: [PATCH] suppress error by overriding class func --- frigate/comms/ws.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/frigate/comms/ws.py b/frigate/comms/ws.py index 1510937791..98f24cf281 100644 --- a/frigate/comms/ws.py +++ b/frigate/comms/ws.py @@ -1,5 +1,6 @@ """Websocket communicator.""" +import errno import json import logging import threading @@ -12,7 +13,7 @@ WSGIServer, ) from ws4py.server.wsgiutils import WebSocketWSGIApplication -from ws4py.websocket import WebSocket +from ws4py.websocket import WebSocket as WebSocket_ from frigate.comms.dispatcher import Communicator from frigate.config import FrigateConfig @@ -20,6 +21,18 @@ logger = logging.getLogger(__name__) +class WebSocket(WebSocket_): + def unhandled_error(self, error): + """ + Handles the unfriendly socket closures on the server side + without showing a confusing error message + """ + if hasattr(error, "errno") and error.errno == errno.ECONNRESET: + pass + else: + logging.getLogger("ws4py").exception("Failed to receive data") + + class WebSocketClient(Communicator): # type: ignore[misc] """Frigate wrapper for ws client."""