Hi,
I am getting lots of 400 HTTP Headers while using polling on socket.io.
I am using nodejs cluster:
Here is the code snippet:
if (cluster.isMaster) {
// Fork workers.
//numCPUs=1;
for (var i = 0; i < numCPUs-1; i++) {
cluster.fork();
}
}
//worker code:
else{
var socket_io = require('socket.io')(server);
var redis_adapter = require('socket.io-redis');
socket_io.adapter(redis_adapter({ host: config.redis.ip, port: config.redis.port }));
//rest of the code
socket_io.on('connection', function (socket) {
}
Any pointer in this regard will be helpful.
Thanks in Advance
Hi! I had a lot of trouble setting up a cluster with socket.io, as there are not a lot of examples. I have a working example i use to control some raspberryPi's at
https://github.com/jordanpappas/raspi-car/tree/master/server
I really need to make a separate example in order to show how to get this working, but for now you can check out the index file in the link. There are a few things you have to be sure to do in order to get this to work.
var io = sio(server, { 'transports': ['websocket'] });
and on client:
var socket = io.connect('http://localhost:3000', { 'transports': ['websocket'] });
This should get you moving in the right direction, and i'll work on getting a simple example together.
Sure thanks.I solved the issue.I was using sticky session library inside cluster worker which is wrong as the library itself creates the workers.
That issue was closed automatically. Please check if your issue is fixed with the latest release, and reopen if needed (with a fiddle reproducing the issue if possible).
Waste 4 hours in this problem
Most helpful comment
Hi! I had a lot of trouble setting up a cluster with socket.io, as there are not a lot of examples. I have a working example i use to control some raspberryPi's at
https://github.com/jordanpappas/raspi-car/tree/master/server
I really need to make a separate example in order to show how to get this working, but for now you can check out the index file in the link. There are a few things you have to be sure to do in order to get this to work.
and on client:
This should get you moving in the right direction, and i'll work on getting a simple example together.