-
Notifications
You must be signed in to change notification settings - Fork 75
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
close() not working or taking a really long time #44
Comments
Well, I worked a way around the problem. Instead for using the close() method, I made a command to disconnect the client from the server side. So when the client wants to disconnect, it sends the "disconnect me" command to the server, and the server does the job. Solved my problem, but I still wonder why the close() method would not work... |
Hi, rreghin The weird thing is that even the device is disconnected, when the server tries to send some message to the device, there is no error and the server still has no idea about the dead connection. |
That's very odd. =( Unfortunately I have no idea on how to help you. Did you try to do the workaround I mentioned in my last post (May 23) ?? |
Yes, I tried. |
Yes, I had the same problem. Actually, I think this is some "TCP/IP stack" feature/issue, and I think it has nothing to do with the WebSockets itself. Its up to the client to send a FIN packet to the server whenever it wants do disconnect. If the client does not send the FIN packet, the server has no way to know the connection is dead. The socket function close(fd) is supposed to do the job, and I think it does it very well. But sometimes for some reason, like a network problem, the server does not receive the FIN packet. But what I think is more likely to happen is the client sends the FIN packet, the server receives it and then reply to it (with an ACK packet), as expected, but the client is already gone and won't reply back to the ACK packet. Then boom, you're server side connection is stuck in a FIN_WAIT_2 state, and there's not much you can do about it. I solved this problem with a server keep alive packet. My server sends a tiny packet to the client every 1 or 2 minutes, and when it gets no response from the client after 2 consecutive packets it just drops the connection. Hope it helps somehow... =) |
Thank you for your explanation. |
Hello again!
I'm having a hard time trying to figure out why the close() method is not working properly.
When using the browser's native version of WebSocket, or the Android's 4.4.x native version (fallback) as well, the close() method works as expected, and it closes the connection right away.
But when using your plugin, it takes forever to close the connection, and eventually the server will close the connection due to innactivity.
Should I do something else other than simply calling the close() method (function) of the object??
The text was updated successfully, but these errors were encountered: