title: nodejs websocket detect disconnected socket
body: <p>I have a nodejs websocket server and I have the following problem.</p>
  
  <p>When my clients connect to the server and terminate gracefully the <code>onclose</code> method is called on those sockets and I perform clean up operations on the closed socket.</p>
  
  <p>When the client disconnects due to network, the <code>onclose</code> method is not called. Is there any timeout to be set so <code>onclose</code> is called automatically after a timeout? </p>
  
  <p>I am using <a href="https://www.npmjs.com/package/ws" rel="noreferrer">ws</a> package for the websocket server in nodejs </p>