Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress frontend websocket error #8431

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
suppress error by overriding class func
  • Loading branch information
hawkeye217 committed Nov 2, 2023
commit 5c71715e0ab286c75f8d43c14e5edfec93444dbd
15 changes: 14 additions & 1 deletion frigate/comms/ws.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Websocket communicator."""

import errno
import json
import logging
import threading
Expand All @@ -12,14 +13,26 @@
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

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."""

Expand Down