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

(fix) Websocket disconnects with 1006 and 1001 errors #15338

Open
Kinzowa opened this issue Oct 18, 2022 · 4 comments
Open

(fix) Websocket disconnects with 1006 and 1001 errors #15338

Kinzowa opened this issue Oct 18, 2022 · 4 comments
Assignees
Labels
bug ws Websockets (a.k.a. PRO)

Comments

@Kinzowa
Copy link

Kinzowa commented Oct 18, 2022

Hello,

A solution has been provided by the Hummingbot community for the bug reported in #14557 and described below. That would be awesome if someone could incorporate the fix within CCXT.

Thank you,

hummingbot/hummingbot#5723

The issue seems to be caused by several different root cause, but ending up closing the websocket connection either when HB expects it (1000 would be normal from the websocket with msg reporting the close status) or unexpectedly (1006, HB is expecting the connection to be open and its internal _connected flag to be True when the websocket is actually closed)

The proposal here is to simply add a auto-reconnect attempt when the websocket tells us that it is closed when we did not initiate the close, or when unexpectedly the websocket is closed. This is achieved either by catching a non-responsive request and attempting a ping, or by not raising an exception, but logging the disconnect, closing the websocket, updating the status of the internal flag and attempting the reconnect

@Kinzowa Kinzowa changed the title Fix - Websocket disconnects with 1006 and 1001 errors Websocket disconnects with 1006 and 1001 errors Oct 18, 2022
@Kinzowa Kinzowa changed the title Websocket disconnects with 1006 and 1001 errors (fix) Websocket disconnects with 1006 and 1001 errors Oct 18, 2022
@sc0Vu sc0Vu self-assigned this Oct 20, 2022
@ttodua ttodua added bug ws Websockets (a.k.a. PRO) labels Oct 24, 2022
@Kinzowa
Copy link
Author

Kinzowa commented Nov 2, 2022

Hello, any news about this bug?

I would like to add that CCXT pro is unusable with the FTX exchange - yet the 2nd exchange in terms of volume - due to untimely disconnections. Resolution of this bug should be top priority.

Testing with multiple cloud providers and server locations (Germany and Singapore which is closer to FTX servers) did not resolve the issue. I also notice that disconnections occur in different VMs around the same time.

@alin3994
Copy link

alin3994 commented Nov 2, 2022

+1

I'm seeing this as well, with a few exchanges. If there's a way for us to reconnect if there's not been a ws event for a while that would work too.

@mayrsascha
Copy link

@sc0Vu @ttodua Is there maybe any update on this? This keeps happening for me as well for multiple exchanges (OKX, Binance, Bybit) in multiple server environments, at seemingly random times.

I get that the fix for this could be complex within CCXT, but it would be nice knowing if there is a way to instruct the Websocket to reconnect when my application catches the error to not miss out on incoming data. @alin3994 @Kinzowa Did you guys perhaps manage to find a workaround in the meantime?

@pcriadoperez
Copy link
Contributor

Hi @mayrsascha, disconnects and errors can happen, that is why we recommend to sorround the watch call in a while loop and a try and catch. On every call to the watch function if the connection has closed for any reason it will reconnect automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ws Websockets (a.k.a. PRO)
Projects
None yet
Development

No branches or pull requests

6 participants