-
Notifications
You must be signed in to change notification settings - Fork 762
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
why on_close only was called once, so it causes the client to reconnect automatically only once, even I set reconnect parameter. #974
Comments
Hey @GooVincent, a few notes:
If you provide complete (runnable via "python client.py") client and server examples, I can take a crack at your issue. |
Here is my complete client.py
and the client will print like following. then stucked, watch the link status, there are two CLOSE_WAIT links.
|
I found to modify the member has_done_teardown, it will work. like:
But I am not sure if it is reasonable. |
I tested your client code against my usual websocket server, @GooVincent, and didn't notice any problem with reconnects - every time I turn the server off and on, the client reconnects without issue. In any case, it sounds like you found a workaround - glad to hear you have a solution, happy coding! |
Perhaps to have a try with my server.py if possible. Yes, setting self.ws.has_done_teardown = False will work. Anyway thanks for all your advice above. |
@GooVincent I tried your server example, and finally see what you mean - this is about reuse of the WebSocketApp instance after the server closes the connection. Hah, I should have read your question more carefully, sorry. Great work determining that this is as simple as flipping that bool - I added your change to this pull request (which addresses an ambiguity related to reconnects): #972. @engn33r I stuck has_done_teardown = False near the top of run_forever(). That pull request also includes a fix related to #971 - LMK what you think. |
This should be fixed in v1.8.0 which includes PR #972. If this reoccurs, we can reopen the issue. |
I think I encountered this as well! This was happening because WrappedDispatcher (via reconnect() and timeout()) wasn't passing reconnecting=True to setSock(). I think this was actually probably my oversight, oops, sorry. Anyway, #983 addresses this issue, and also some related stuff. Anyone having reconnect (or async write) issues, please LMK if this branch improves things on your end! |
Hi, everyone, I am trying to implement reconnecting ws server when close by the ws server. What I am using websocket-client version is 1.7.0. And I found on_close was just triggerd once when the ws server closed the socket.
Following is my demo code.
client.demo
server.demo
What I wanna is the client will keep reconnecting to the server, as I call run_forever() again in on_close, but it only happen once, why?
Please anyone could help me on this?
The text was updated successfully, but these errors were encountered: