question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Websocket exception not caught

See original GitHub issue

Version of this library.

1.40.5

Solution to Issue cannot be found in the documentation or other Issues and also occurs in the latest version of this library.

  • I checked the documentation and other Issues. I am using the latest version of this library.

Hardware?

VPS or other cloud hosting

Operating System?

Linux

Python version?

Python3.8

Installed packages

No response

Logging output

No response

Processing method?

stream_buffer

Used endpoint?

binance.com

Issue

Hello,

I am using the exact same config as in #235 and the same code basically.

Since version 1.40.5, I noticed that while I am streaming data via the websockets, there is now that message that pops. It does not seem to affect the reconnexion of the websocket, but it does make the logs pretty bad-looking x) Do you plan on keeping it as it currently is, or wouldn’t it be better to catch this?

Task exception was never retrieved
future: <Task finished name='Task-237' coro=<BinanceWebSocketApiSocket.start_socket() done, defined at /home/charlyvps/.local/lib/python3.8/site-packages/unicorn_binance_websocket_api/sockets.py:63> exception=Sy
stemExit(1)>
Traceback (most recent call last):
  File "/home/charlyvps/.local/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 944, in transfer_data
    message = await self.read_message()
  File "/home/charlyvps/.local/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 1013, in read_message
    frame = await self.read_data_frame(max_size=self.max_size)
  File "/home/charlyvps/.local/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 1088, in read_data_frame
    frame = await self.read_frame(max_size)
  File "/home/charlyvps/.local/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 1143, in read_frame
    frame = await Frame.read(
  File "/home/charlyvps/.local/lib/python3.8/site-packages/websockets/legacy/framing.py", line 70, in read
    data = await reader(2)
  File "/usr/lib/python3.8/asyncio/streams.py", line 721, in readexactly
    raise exceptions.IncompleteReadError(incomplete, n)
asyncio.exceptions.IncompleteReadError: 0 bytes read on a total of 2 expected bytes

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/charlyvps/.local/lib/python3.8/site-packages/unicorn_binance_websocket_api/sockets.py", line 115, in start_socket
    received_stream_data_json = await websocket.receive()
  File "/home/charlyvps/.local/lib/python3.8/site-packages/unicorn_binance_websocket_api/connection.py", line 280, in receive
    received_data_json = await self.manager.websocket_list[self.stream_id].recv()
  File "/home/charlyvps/.local/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 552, in recv
    await self.ensure_open()
  File "/home/charlyvps/.local/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 920, in ensure_open
    raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: no close frame received or sent

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/charlyvps/.local/lib/python3.8/site-packages/unicorn_binance_websocket_api/manager.py", line 525, in _create_stream_thread
    loop.run_forever()
  File "/usr/lib/python3.8/asyncio/base_events.py", line 570, in run_forever
    self._run_once()
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1859, in _run_once
    handle._run()
  File "/usr/lib/python3.8/asyncio/events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "/home/charlyvps/.local/lib/python3.8/site-packages/unicorn_binance_websocket_api/sockets.py", line 211, in start_socket
    sys.exit(1)
SystemExit: 1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
oliver-zehentleitnercommented, Mar 24, 2022

Thank you.

I’ll open this again, still takes time to get a final and well tested version

1reaction
oliver-zehentleitnercommented, Apr 18, 2022

I think the next version will be fine, i release it today

Read more comments on GitHub >

github_iconTop Results From Across the Web

Javascript doesn't catch error in WebSocket instantiation
The WebSocket 's connection-time error causes a dispatched event, not a thrown value. This is because throw operations must be synchronous.
Read more >
Exception not reaching outer try catch · Issue #33
I put the whole Loop doing a websocket in a try... catch( Exception $e ) { If there is a problem, like I...
Read more >
Exceptions - websockets 10.4 documentation
websockets.exceptions defines the following exception hierarchy: ... Raised to abort the handshake on purpose and return a HTTP response. This exception is an ......
Read more >
977020 - websocket send raises uncaught exception
> The exception is caught in the window.onerror handler, and not by the catch instruction That's really weird. While non-exception things do get...
Read more >
How to catch Broken pipe exception when send something ...
When netty websocket server is shutdown ungracefully like recent app clean, websocket client does not receive any event. At that time, if websocket...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found