Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SocketIO + Node - Recovering Lost Connections

Im using socketio/node, to pump out some funky stats to the browser, all standard stuff. I am using the latest versions of both libraries. Now, i am having a couple of issues with this:

1) Warning messages in the node log:

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace: 
    at CleartextStream.<anonymous> (events.js:101:17)
    at [object Object].<anonymous> (/var/www/lib/other/Socket.IO/lib/socket.io/client.js:83:20)
    at [object Object]._onConnect (/var/www/lib/other/Socket.IO/lib/socket.io/transports/xhr-polling.js:23:35)
    at [object Object].check (/var/www/lib/other/Socket.IO/lib/socket.io/listener.js:77:12)
    at Server.<anonymous> (/var/www/lib/other/Socket.IO/lib/socket.io/listener.js:33:14)
    at Server.emit (events.js:45:17)
    at HTTPParser.onIncoming (http.js:904:12)
    at HTTPParser.onHeadersComplete (http.js:87:31)
    at CleartextStream.ondata (http.js:820:22)
    at CleartextStream._blow (tls.js:228:29)

This is an example of an XHR warning, which i can kinda understand as the nature of XHR is multiple connects/disconnects. However, when i have quite a few clients connected by other transports i get the same.

2) Random connection drop outs. For some inexplicable reason, connections randomly drop out. This isnt machine or browser or even transport specific. The connection on a browser will just randomly stop receiving updates. There is no specific disconnect message in the node logs and manually refreshing the browser fixes the problem.

So, what im wondering is - are these 2 issues related, or separate issues? Have you experienced these connection drop outs? If so, how have you managed to solve them? Its quite frustrating, as its so close to being 100% perfect. I would love to feel warm and snug in the knowledge that all clients viewing the pages of my application would receive consistent updates for hours, even days if they wanted.

Your help and advice is much appreciated!

Cheers,

Pete

like image 579
Peter John Avatar asked Feb 03 '11 10:02

Peter John


2 Answers

I wish I had a solid answer for you sir, but I can at least provide you with a sanity check.

I've been messing with the library for about a week now, and I've seen that exact error, and additional errors where a websocket connection can't be persisted (on browsers that support the technology naturally), random session id drops. In general, ust about nothing works reliably.

In all fairness, it is free and still in beta, so there you have it.

Socket.io is one buggy library.

like image 87
Mason Houtz Avatar answered Sep 22 '22 13:09

Mason Houtz


Well I have part of the answer. According to Guillermo Rauch (the creator of socket.io) this error is not really a memory leak, because on a full disconnect it will get cleared. Here is the link to the mailing list that explains it.

So it is unlikely that these two problems are related. I experience the warning message as well, but I haven't had a problem with the random drop outs.

like image 20
Anton Avatar answered Sep 21 '22 13:09

Anton