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
this.ws.onclose = function(){
//try to reconnect in 5 seconds
console.log("WS CLOSED. RECONNECT IN 5 SECS");
setTimeout(function(){self.startNative()}, 5000);
};
I start server with following 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
});
What can cause it ?