Socket not cleanly closed when use cluster and socket.io with RedisStore
When I use cluster and RedisStore ,then always there are 10% socket connected all the time , I judget it by var sock = io.sockets.sockets[sid]; if (sock != undefined && sock.disconnected == false) { //connected }else{ //disconnected } Yesterday, I ran application in single process(without cluster) ,all of sockets closed;
Hi i'm having similar issue with RedisStore, may be we can help each other. Check out this links: https://github.com/LearnBoost/socket.io/issues/831 https://github.com/SpiderStrategies/socket.io/commit/caa96a5cc207aaff23db94a03a2412f5a8c8a4f6 https://github.com/observing/socket.io/commit/6d458d86697ddd8b10f68905fec02ca9feb3541c
Can you tell where did you add the piece of code? did you fix something with it or was just for checking? Thanks
I store all socket id in my db , when I found that some socket didn't clear , I tried to clear them in the same process. but it doesn't works. sorry,I still doesn't fix it :( ; I will try your method and tell you whether it works ^_^
great, that links help me to fix part of the issue, I still have some references to Socket objects that must be deleted. On monday i will work hard with de socket.io garbage collector (in manager.js) to look for a fix. My worst problem is that after some days of the servers running i run out of memory, so this issue is causing memory leaks. I hope we can fix this :)
Your method seems doesn't work on my application . and I got the memory issue today...
That's bad, can you find out the number of opened sockets when the leaks happen? I'm now trying to do some test cases in order to find a fix. I'll see how the memory behaves these days and tell you.
I'm ising this to list my socket objects. Maybe you find it useful
app.get("/socketInfo", function(req, res){ var numberOfSockets = Object.keys(socketIO.connected).length; var socketIds = socketIO.rooms[''] ? socketIO.rooms[''] : []; var data = { numberOfSockets: numberOfSockets, socketIds: socketIds, connected: socketIO.connected, open: socketIO.open, closed: socketIO.closed, rooms: socketIO.rooms, roomClients: socketIO.roomClients, handshaken: socketIO.handshaken }; res.json(data); });
about 100-300 socket connections