-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sticky-session: worker died error TypeError: Cannot call method 'removeListener' of undefined #22
Comments
the same problem when high concurrent connection number |
@liebo @Alexandrrr I have the same issue. I use sitcky session with socket.io. How can we setup a high-traffic websocket server? Here is my app: (function() {
var admSecret, os, redis, socketPort, sticky;
os = require('os');
redis = require('socket.io-redis');
sticky = require('sticky-session');
socketPort = 3000;
sticky(function() {
var handler, importantNotice, io, server;
handler = function(req, res) {
res.writeHead(200);
return res.end('vgws: ' + process.pid);
};
server = require('http').createServer(handler);
io = require('socket.io')(server);
io.adapter(redis({
host: 'localhost',
port: 6379
}));
io.on('connection', function(socket) {
socket.on('important-notice', function() {
return socket.emit('important-notice', importantNotice);
});
});
return server;
}).listen(socketPort, function() {
console.log(process.pid);
});
}).call(this); Error in high traffic period
|
Cause of error: Solution: add a validation variable. For example: process.on('message', function(msg, socket) {
if (msg !== 'sticky-session:connection') return;
if (socket) {
server.emit('connection', socket);
} else {
console.log('Warning: socket is not defined');
}
}); |
Thank you @Mad-Head so much. |
Hello.
I had a problem with my project. If I hold down the button F5 to reload my page, which is rendered by GET request, nodeserver is down with exception:
sticky-session: worker died
error TypeError: Cannot call method 'removeListener' of undefined
CallStack:
at httpSocketSetup (http.js:1859:10)
at Server.connectionListener (http.js:1928:3)
at Server.emit (events.js:95:17)
at process. (/var/www/producer/data/www/producer.lifeha.ru/project/node_modules/sticky-session/lib/sticky-session.js:63:14)
at process.emit (events.js:117:20)
at handleMessage (child_process.js:322:10)
at Pipe.channel.onread (child_process.js:349:11)
sticky-session: worker died
The text was updated successfully, but these errors were encountered: