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

Websocket exception #64

Closed
carlos-evolutive opened this issue Apr 8, 2019 · 4 comments
Closed

Websocket exception #64

carlos-evolutive opened this issue Apr 8, 2019 · 4 comments

Comments

@carlos-evolutive
Copy link

The websocket sometimes gives an exception but it is not clear if it reconnects...

Task exception was never retrieved
future: <Task finished coro=<StreamConn._consume_msg() done, defined at /opt/conda/lib/python3.6/site-packages/alpaca_trade_api/stream2.py:46> exception=ConnectionClosed('WebSocket connection is closed: code = 1006 (connection closed abnormally [internal]), no reason',)>
Traceback (most recent call last):
File "/opt/conda/lib/python3.6/site-packages/websockets/protocol.py", line 674, in transfer_data
message = yield from self.read_message()
File "/opt/conda/lib/python3.6/site-packages/websockets/protocol.py", line 742, in read_message
frame = yield from self.read_data_frame(max_size=self.max_size)
File "/opt/conda/lib/python3.6/site-packages/websockets/protocol.py", line 815, in read_data_frame
frame = yield from self.read_frame(max_size)
File "/opt/conda/lib/python3.6/site-packages/websockets/protocol.py", line 884, in read_frame
extensions=self.extensions,
File "/opt/conda/lib/python3.6/site-packages/websockets/framing.py", line 99, in read
data = yield from reader(2)
File "/opt/conda/lib/python3.6/asyncio/streams.py", line 674, in readexactly
yield from self._wait_for_data('readexactly')
File "/opt/conda/lib/python3.6/asyncio/streams.py", line 464, in _wait_for_data
yield from self._waiter
concurrent.futures._base.CancelledError

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

Traceback (most recent call last):
File "/opt/conda/lib/python3.6/site-packages/alpaca_trade_api/stream2.py", line 50, in _consume_msg
r = await ws.recv()
File "/opt/conda/lib/python3.6/site-packages/websockets/protocol.py", line 434, in recv
yield from self.ensure_open()
File "/opt/conda/lib/python3.6/site-packages/websockets/protocol.py", line 658, in ensure_open
) from self.transfer_data_exc
websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 1006 (connection closed abnormally [internal]), no reason

@aprsa
Copy link

aprsa commented May 8, 2019

Same issue here; it does not reconnect as no new messages come through the stream. Alpaca never passes the exception. Could it be that the websocket doesn't raise an exception so that alpaca api cannot catch it?

@rvishal11
Copy link

Its an open bug: https://github.com/aaugustin/websockets/labels/bug

Its added as a milestone for the 8.0(https://github.com/aaugustin/websockets/milestone/4) release

bdowling added a commit that referenced this issue Jul 10, 2019
bdowling added a commit that referenced this issue Jul 10, 2019
bdowling added a commit that referenced this issue Jul 10, 2019
@alexonab
Copy link
Contributor

Could the reconnect handling that was added to polygon streamconn also be added to the default streamconn?

@umitanuki
Copy link
Contributor

I believe the websocket connection handling has changed over time. Please open a new issue if you encounter new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants