-
Notifications
You must be signed in to change notification settings - Fork 518
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 connection closed: connection was closed uncleanly ("peer dropped the TCP connection without previous WebSocket closing handshake") #180
Comments
|
Hi! I am having issues also quite similar.....The recovery on my end is to restart the whole computer (ubuntu) since once the websocket is gone its gone forever.....python application stop->start does not solve the issue. And after restarting the application the websocket is still unseless....On my end I suspect that in my _user_data_handler there is a call aslo to binance via spot API which might take too long sometimes so maybe this could block some threads (not sure) and therefore the websocket is blocked too long....do you also have an SPOT API call in the code of the _user_data_handler after the "...." part? |
I debugged my code and let it run for quite a while. I am sure its not blocking any threads now and still the websocket stops sending messages and I get the same issue reported in your ticket.... "WebSocket connection closed: connection was closed uncleanly ("peer dropped the TCP connection without previous WebSocket closing handshake"), code: 1006, clean: False, reason: connection was closed uncleanly ("peer dropped the TCP connection without previous WebSocket closing handshake")" meanwhile the server does not block me: {'data': {'isLocked': False, 'plannedRecoverTime': 0, 'triggerCondition': {'UFR': 300, 'IFER': 150, 'GCR': 150}, 'updateTime': 0}} |
Hi sir: |
Hi! Thanks for you comment! Well I am querying the binance spot account every minute (which needs auth) meanwhile the websocket runs.....and after a while it stops sending messages. Do I understand it correctly from your comments that if I send any auth request to binance within 1 minute timeframes the websocket connection shall remain alive? |
I think the userdata stream is only activated for requests involving account changes. |
Thx for the suggestion for the workaround. I'will try it....meanwhile I've checked the available pull requestes and it seems there is a fix for the websocket client...so I took it over (reactor.stop() was replaced) maybe this causes the socket issue with the closure...I have not check it so its a maybe... Also I've checked the docu of binance and the websocket shall be kept alive for 24 hours without sending any userdata... "A single connection to stream.binance.com is only valid for 24 hours; expect to be disconnected at the 24 hour mark The ping-pong is handled in the binance-connector .... |
Hi. |
Hi sir, Do you mean subscribing to multiple streams by one ws client at the same time or multiple ws clients at the same time? |
hi gents! on my end it seems that the websocket ping-pong is fine. in case o pong from the server ping is sent. One time the socket died when after binance server sent a pong....(I did not find any description when it is done usually it sends a ping). But in an other case everything was fine (ping was sent and pong was replied etc) and shortly after the websocket died. I am not sure if the same payload has to be sent back to the server (I've found no docu on this probably not....) Mine is:
|
22.7.1 |
I have 5 clients running now. Each client is running a subscription to 100 streams. 4 clients work without problems, and the described problem occurs on one client |
"I have 5 clients running now. Each client is running a subscription to 100 streams. 4 clients work without problems, and the described problem occurs on one client" When you mean 5 clients running: you mean the same SW python environment / docker container + same computer is used for every client or they are on a different PC or might use different package versions? (what could be the difference between the 4 client and the 1 on which the issue could be reproduced?) |
Different computers. Everything else is the same |
When you mean same:
I think your setups are really valuable to find out what could be the root cause of this issue! update: |
Please check the v3 websocket which has the new design. We are happy to collect more feedbacks to improve it. |
If I'm running the code on my comp it fails, with the above mentioned error code, but if I run it in a docker container, complied with the same requriements.txt file, same python version, it works... so not sure why, but I have to use docker for local development as well. |
When I subscribe to userdata, since my account information doesn't change very often, the following warning appears and the TCP is dropped by the server. What can I do to avoid the subscription being interrupted by the server. By the way, the depth subscribe works fine
Issue subject
[2022-11-06 12:06:48 binance_client_protocol.py-WARNING]: WebSocket connection closed: connection was closed uncleanly ("peer dropped the TCP connection without previous WebSocket closing handshake"), code: 1006, clean: False, reason: connection was closed uncleanly ("peer dropped the TCP connection without previous WebSocket closing handshake")
[2022-11-06 12:06:48 binance_client_factory.py-ERROR]: Lost connection to Server. Reason: [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionDone'>: Connection was closed cleanly.
].
Expected behaviour
subscribe UserData stream with no error
Actual behaviour
TCP is dropped by the server
Steps to reproduce
Receive userdata at low frequency
Environment
Provide any relevant information about your setup, such as:
The text was updated successfully, but these errors were encountered: