title: Why websocket server closes connections?
body: <p><a href="https://i.stack.imgur.com/U7E2s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U7E2s.png" alt="enter image description here"></a></p>
  
  <p>I have websocket nodejs server with ~2000 concurrent connections and server closes them periodically. I don't know the reason.
  I catch it in my client code </p>
  
  <pre><code> this.ws.onclose = function(){
          //try to reconnect in 5 seconds
          console.log("WS CLOSED. RECONNECT IN 5 SECS");
          setTimeout(function(){self.startNative()}, 5000);
      };
  </code></pre>
  
  <p>I start server with following code</p>
  
  <pre><code>var WebSocketServer = require('ws');
  
  //start websockets server
  var webSocketServer = new WebSocketServer.Server({port: config.port2}, function () {
      console.log("Native websocket server process running on " + config.port2);
  });
  
  //websockets connection
  webSocketServer.on('connection', function(ws, req) {
      ws.on('close', function() {
          //somecode
      });
  </code></pre>
  
  <p>What can cause it ?</p>