Skip to content
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

Getting HTTP Header 400 while using polling on socket.io #2091

Closed
shashuec opened this issue Apr 22, 2015 · 4 comments
Closed

Getting HTTP Header 400 while using polling on socket.io #2091

shashuec opened this issue Apr 22, 2015 · 4 comments

Comments

@shashuec
Copy link

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

@jordanpappas
Copy link

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.

  1. Use redis (you already seem to be doing that, so compare how you wired up the adapter to my example)
  2. Use websockets only. This is true for both clients and the server. These errors you are getting have to do with the polling stuff, so don't use it. Do this like this
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.

@shashuec
Copy link
Author

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.

@darrachequesne
Copy link
Member

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).

@michaelyou
Copy link

Waste 4 hours in this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@shashuec @jordanpappas @michaelyou @darrachequesne and others