`websocksets.ConnectionClosedError` may be raised in keepalive situations
Vaelor opened this issue · 0 comments
See #86 (comment)
I believe websocksets.ConnectionClosedError
may be raised here in situations where one would want the keepalive to persist. For instance, if prototyping a bot on a laptop that suspends sometimes, you may get something like:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/websockets-8.1-py3.9-linux-x86_64.egg/websockets/protocol.py", line 827, in transfer_data
message = await self.read_message()
File "/usr/local/lib/python3.9/dist-packages/websockets-8.1-py3.9-linux-x86_64.egg/websockets/protocol.py", line 895, in read_message
frame = await self.read_data_frame(max_size=self.max_size)
File "/usr/local/lib/python3.9/dist-packages/websockets-8.1-py3.9-linux-x86_64.egg/websockets/protocol.py", line 971, in read_data_frame
frame = await self.read_frame(max_size)
File "/usr/local/lib/python3.9/dist-packages/websockets-8.1-py3.9-linux-x86_64.egg/websockets/protocol.py", line 1047, in read_frame
frame = await Frame.read(
File "/usr/local/lib/python3.9/dist-packages/websockets-8.1-py3.9-linux-x86_64.egg/websockets/framing.py", line 105, in read
data = await reader(2)
File "/usr/lib/python3.9/asyncio/streams.py", line 723, in readexactly
await self._wait_for_data('readexactly')
File "/usr/lib/python3.9/asyncio/streams.py", line 517, in _wait_for_data
await self._waiter
File "/usr/lib/python3.9/asyncio/selector_events.py", line 856, in _read_ready__data_received
data = self._sock.recv(self.max_size)
ConnectionResetError: [Errno 104] Connection reset by peer
The above exception was the direct cause of the following exception:
File "/home/pde/src/mmpy_bot/mmpy_bot/bot.py", line 88, in run
self.event_handler.start()
File "/home/pde/src/mmpy_bot/mmpy_bot/event_handler.py", line 44, in start
self.driver.init_websocket(self._handle_event)
File "/usr/local/lib/python3.9/dist-packages/mattermostdriver-7.2.0-py3.9.egg/mattermostdriver/driver.py", line 148, in init_websocket
File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/usr/local/lib/python3.9/dist-packages/mattermostdriver-7.2.0-py3.9.egg/mattermostdriver/websocket.py", line 51, in connect
File "/usr/local/lib/python3.9/dist-packages/mattermostdriver-7.2.0-py3.9.egg/mattermostdriver/websocket.py", line 63, in _start_loop
File "/usr/lib/python3.9/asyncio/tasks.py", line 481, in wait_for
return fut.result()
File "/usr/local/lib/python3.9/dist-packages/mattermostdriver-7.2.0-py3.9.egg/mattermostdriver/websocket.py", line 108, in _wait_for_message
File "/usr/local/lib/python3.9/dist-packages/websockets-8.1-py3.9-linux-x86_64.egg/websockets/protocol.py", line 509, in recv
await self.ensure_open()
File "/usr/local/lib/python3.9/dist-packages/websockets-8.1-py3.9-linux-x86_64.egg/websockets/protocol.py", line 803, in ensure_open
raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: code = 1006 (connection closed abnormally [internal]), no reason
_Originally posted by @pde in https://github.com/Vaelor/python-mattermost-driver/pull/86#discussion_r601958017_