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 Server not detecting when Websocket client is disconnected #71

Closed
elC0mpa opened this issue Mar 11, 2020 · 4 comments
Closed

Comments

@elC0mpa
Copy link

elC0mpa commented Mar 11, 2020

Hello, this issue is almost the same as the one dedcribed here #44.
I am using your library to connect to a websocketserver (the same as the referenced issue).
The thing is that when I turn off the microcontroller which is working as a client, the server don't detect it.
In order to debug, I called the method close() and the server crashes when this happens.
I hope you can help me. Thanks in advance

@gilmaimon
Copy link
Owner

What server impl are you using?
When you shutdown the microcontroller no fin packet is being sent to the server, so it does not know that a client disconnected. This is not a bug in the client/server, it's just a real-world physical limitation.
Regarding close() making the server crash, that's really wierd. It might be a bug with the server implementation you are using.

Gil.

@elC0mpa
Copy link
Author

elC0mpa commented Mar 14, 2020

Hello @gilmaimon, I didnt know that the server is not able to detect when the microcontroller is turned off. I am using the same server as in the referenced issue, the async one, maybe it is the same problem but now with the close packet.
By the way, let me ask you something, what can I do in order to realize when the clients were disconnected?

@gilmaimon
Copy link
Owner

Sorry for the very delayed comment.

In order to know which clients are actually alive, the server can send a "keep-alive" ping and disconnect any clients that do not send pong after some chosen interval. This is a common approach, it is actually already implemented in many websockets servers.

Also, just the act of trying to send a packet to the client will result in a tcp error (because no ack will be returned to the server), so you might not even need to wait for a pong.

Gil.

@elC0mpa
Copy link
Author

elC0mpa commented Apr 14, 2020

Thanks @gilmaimon, I appreciate your help

@elC0mpa elC0mpa closed this as completed Apr 14, 2020
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

2 participants