Flotype / now

NowJS makes it easy to build real-time web apps using JavaScript
http://www.nowjs.com
MIT License
1.91k stars 175 forks source link

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit. #52

Closed Azerothian closed 13 years ago

Azerothian commented 13 years ago

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit. Trace: at Socket. (events.js:123:17) at [object Object]. (/usr/local/lib/node/.npm/socket.io/0.6.16/package/lib/socket.io/client.js:83:20) at [object Object]._onConnect (/usr/local/lib/node/.npm/socket.io/0.6.16/package/lib/socket.io/transports/xhr-polling.js:23:35) at [object Object].check (/usr/local/lib/node/.npm/socket.io/0.6.16/package/lib/socket.io/listener.js:77:12) at HTTPServer. (/usr/local/lib/node/.npm/socket.io/0.6.16/package/lib/socket.io/listener.js:33:14) at HTTPServer.emit (events.js:67:17) at HTTPParser.onIncoming (http.js:1108:12) at HTTPParser.onHeadersComplete (http.js:108:31) at Socket.ondata (http.js:1007:22) at Socket._onReadable (net.js:677:27) -- Modules -- socket.io@0.6.17 nowjs 0.5.1 express jade

----- app.js ------ var util = require('util');

var express = require('express');

var app = module.exports = express.createServer();

var users = {};

// Configuration

app.configure(function(){ app.set('views', dirname + '/views'); app.set('view engine', 'jade'); app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(app.router); app.use(express.static(dirname + '/public')); });

app.configure('development', function(){ app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); });

app.configure('production', function(){ app.use(express.errorHandler()); });

// Routes

app.get('/', function(req, res){ res.render('index', { pageTitle: 'Nadir' }); });

// Only listen on $ node app.js

if (!module.parent) { app.listen(80); console.log("Express server listening on port %d", app.address().port);

var nowjs = require('now');
var everyone = nowjs.initialize(app);

everyone.now.distributeMessage = function(message){
    everyone.now.receiveMessage(this.now.name, message);
};

everyone.now.userConnect = function(userName){
    userConnected(this, userName);
};
everyone.now.Hello = function() {

}
everyone.connected(function(){
    //userConnected(this);

});
everyone.disconnected(function(){
    userDisconnected(this);

});

} function userConnected(user, userName) { user.now.name = userName; users[user.user.clientId] = user; everyone.now.receiveStatusMessage( userName + " has connected."); sendUserList(); }

function userDisconnected(user) { everyone.now.receiveStatusMessage( user.now.name + " has disconnected."); delete users[user.user.clientId]; sendUserList(); }

function sendUserList() { var userDetailList = {};

for(var i in users)
{
    userDetailList[users[i].user.clientId] = 
    { 
        clientId: users[i].user.clientId, 
        Name: users[i].now.name 
    };
}

for(var i in users)
{
    users[i].now.updateUserList(userDetailList);
}

}

dvv commented 13 years ago

/socket.io/0.6.16/ must be 0.6.17

tglines commented 13 years ago

We thought this issue was closed and fixed but it seems that there may be more to it.

I noticed when updating from socket.io 0.6.16 -> 0.6.17 it cut down the frequency of occurrance drastically, yet it still did happen now and then.

ericz commented 13 years ago

I am experiencing this too especially when using xhr polling . I believe this is purely a socket.io issue though