Skip to content

websocket info

Jeff Schaller edited this page Nov 12, 2023 · 6 revisions

Issue https://github.com/Charcoal-SE/SmokeDetector/issues/7043; Make editwatcher and deletionwatcher more like websocket

Most recent occurrence was: 2022-05-31T16:34:03Z; https://chat.stackexchange.com/search?q=ConnectionResetError+excepthook.py&user=&room=11540

websocket's logic is in https://github.com/Charcoal-SE/SmokeDetector/blob/075901435e175a25939d82886b5285694f633f3d/metasmoke.py#L170

                while True:
                    a = GlobalVars.metasmoke_ws.recv()
                    try:
                        data = json.loads(a)
                        Metasmoke.handle_websocket_data(data)
                        GlobalVars.MSStatus.succeeded()
                        failed_connection_attempts = 0
                    except ConnectionError:
                        raise
                    except Exception as e:
                        log('error', '{}: {}'.format(type(e).__name__, e))
                        log_current_exception()
                        GlobalVars.MSStatus.failed()
                        Metasmoke.connect_websocket()

update the code inside: https://github.com/Charcoal-SE/SmokeDetector/blob/075901435e175a25939d82886b5285694f633f3d/editwatcher.py#L54

Error:

### ConnectionResetError on teward/Osiris at 2022-05-31T16:34:03Z: [Errno 104] Connection reset by peer
File "/home/smokey/SmokeDetector/excepthook.py", line 44, in run_with_except_hook
run_old(*args, **kw)
File "/usr/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/smokey/SmokeDetector/editwatcher.py", line 56, in _start
msg = self.socket.recv()

According to https://websockets.readthedocs.io/en/stable/reference/exceptions.html, ConnectionResetError is not thrown by websocket