I have a nodejs websocket server and I have the following problem.
When my clients connect to the server and terminate gracefully the onclose method is called on those sockets and I perform clean up operations on the closed socket.
When the client disconnects due to network, the onclose method is not called. Is there any timeout to be set so onclose is called automatically after a timeout?
I am using ws package for the websocket server in nodejs
解决方案
default ws implementation doesn't have a callback for network disconnects from client side
You can find a keepAlive implementation here