I'm node.js beginner. Trying to create simple chat app, but have problem. When refreshed page fast 10+ times I have warning:
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
When I disabled socket.io, this warning disapears. So, problem with socket.io. How to increase max listeners for socket.io? Or maybe another solution?
Code:
var http = require('http')
fs = require('fs');
var server = http.createServer(function(req, response) {
req.setMaxListeners(0);
var pathname = __dirname + '/index.html'
fs.readFile(pathname, "binary", function(err, file) {
if (err) {
response.writeHead(500, {'Content-Type': 'text/plain'});
response.end(err);
} else {
response.writeHead(200, {'Content-Type': 'text/html'});
response.write(file, "binary");
response.end();
}
});
});
io = require('socket.io').listen(server);
server.listen(4567);
maxListener
in the first place? Maybe GC is to slow. Also I am not sure if socket.io is fine in this quite incomplete state you are using it. - TheHippo