Replies: 11 comments
-
The |
Beta Was this translation helpful? Give feedback.
-
@miguelgrinberg Thank you for the quick response! Is there any way at all to control the disconnect on the developer's end? |
Beta Was this translation helpful? Give feedback.
-
@jsib0 I don't understand what you mean by "control the disconnect". You are trying to disconnect from the server when there is no connectivity, that's the problem. At that point you are already disconnected. Are you using a disconnect handler? The handler will be called when the disconnection is detected. |
Beta Was this translation helpful? Give feedback.
-
What I meant was to clean up the processes using of socket Client. Since calling |
Beta Was this translation helpful? Give feedback.
-
@jsib0 You did not answer my question. Do you have a disconnect handler set up? Is it not getting called? |
Beta Was this translation helpful? Give feedback.
-
When I call
|
Beta Was this translation helpful? Give feedback.
-
Calling disconnect when you don't have connectivity is not really a use case that I envisioned, so let's set that one aside and look at the other use cases. Are you implying that the disconnect handler is only called when you have a single reconnection attempt? What happens when you have more than one? |
Beta Was this translation helpful? Give feedback.
-
I noted that to imply that if I used this path as a way to disconnect, that it works the way I would like to. And it does call the disconnect handler. I am sure the disconnect handler will also be triggered if I adjusted it to 10. I tried 3 and it works. |
Beta Was this translation helpful? Give feedback.
-
@jsib0 I still don't understand what's broken. As I said, the client handles abrupt disconnections on its own, it does not need help from you. Anything else you try to do will interfere. You are now mentioning a lot of use cases that do work as expected. Can you please tell me what are the use cases that do not work, so that I determine if there is a bug or user error? Also, you shouldn't be tapping into the low level Engine.IO handlers. Those are not a public part of the API and I reserve the right to change them at any time without deprecation or actually any notice. |
Beta Was this translation helpful? Give feedback.
-
@miguelgrinberg I see what you mean. What I am trying to do is relay to the user whether the device is connected to the server, which is through the socket connection. On the device, the user is able to see the wifi connection as well. If the wifi is disconnected, a server connection is technically not possible, thus not true; however, python-socketio maintains a "connected" state until the amount of reconnection tries is exhausted. With all the python-socketio and flask-socketio settings, the connected state would stay for about 25 seconds. There are work-arounds in this problem, but we wanted a true source of truth to be relayed to the user - this also gives us the assurance that the device is at a true disconnected state. |
Beta Was this translation helpful? Give feedback.
-
This is actually incorrect. The connect and disconnect handlers are called for each connection. It does not matter that you have retries enabled, when a connection is gone, the disconnect handler is called, then the retries begin, and once a connection is reestablished you will get another call on the connect handler. It is really up to the networking stack on your device when a connection is reported as gone. In general this only happens when you read or write from the socket, there is no actual disconnect notification in low-level networking. The 25 second delay is because you probably aren't sending any data on this socket, so the disconnection is detected when the ping/pong exchange is attempted, every 25 seconds. If you find out about the networking stack going away through a different mechanism, then the best thing you can do is let Socket.IO do its thing, as it will eventually recognize that the network is gone. |
Beta Was this translation helpful? Give feedback.
-
Hello.
I am trying to disconnect the socket connection when I detect that the WiFi of my machine is disconnected. However, when I perform a disconnect() when the WiFi is disconnected, I receive the following logs below then the main thread stops right after. It takes time for the main thread to revive... Any directions to move forward is highly appreciated. Thank you in advance.
Client logs:
Code to disconnect
Beta Was this translation helpful? Give feedback.
All reactions