Pavan K Pavan K - 1 year ago 262
Node.js Question

nodejs websocket detect disconnected socket

I have a nodejs websocket server and I have the following problem.

When my clients connect to the server and terminate gracefully the

method is called on those sockets and I perform clean up operations on the closed socket.

When the client disconnects due to network, the
method is not called. Is there any timeout to be set so
is called automatically after a timeout?

I am using ws package for the websocket server in nodejs

Answer Source

default ws implementation doesn't have a callback for network disconnects from client side

You can find a keepAlive implementation here

I am not sure why my post was downvoted. At least leave a comment what was wrong?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download