Socket.io: Socket.io pm2 on shutdown doesnt closes sockets

Created on 11 Nov 2016  路  4Comments  路  Source: socketio/socket.io

This issue follows https://github.com/Unitech/pm2/issues/2508
The problem is if i restart or reload socket.io server via pm2, i still have many sockets left online (as far as i understood), so as a result i have cpu load and memory spikes.

Also as a precursor of this problem, no matter which mode (fork or cluster) my server is running, my active sockets count is growing (without sharp jumps, for example: 4000, 3995, 4010, 4005, 4020, but still constantly) with time, what needs more and more memory and as a result i have memory leak?

Most helpful comment

I am a beautiful person who is a great day and night

All 4 comments

About connection count what is rising constantly - it's not pm2 problem, i turned down nginx, pm2, cluster and left only one instance which i run on pure node.js with "node server.js" command without any parameters. So who will read this in future, my connection count problem is NOT because of PM2.

Problem is mobile clients, they ignore socket.io connection/reconnection settings, and despite server was offline for 3 days, they still pingin it, and then server goes online, they reconnects. So if port was public once, and there is still open clients with this port, you will have my situation.

I am a beautiful person who is a great day and night

@Nerfair which socket.io client do the mobile clients use? socket.io-client? Or the native ones (Android/iOS)?

@darrachequesne I am not sure i understood right but it's standart

<script src="https://cdn.socket.io/socket.io-1.4.5.js"></script>
<script>
    var socket = io('http://localhost');
    socket.on('message', function (data) {
        console.log(data);
    });
</script>

and on server side it is

sio = require('socket.io')
Was this page helpful?
0 / 5 - 0 ratings