-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
1.0.0-pre "Session ID unknown" #1503
Comments
Thanks for reporting @ceram1. Can you repeat this problem with 1.0.2? If so, it would be interesting to see the client side debug logs too and/or get some sample code to reproduce the issue. Would help a lot. :) |
Ah.. sorry... The mail was in spam... I'll test it soon |
+1 |
Hi guys, response: just with more than 1 instance on Heroku. Initialisation:
sub = redis.createClient(redisPort, redisHost,{return_buffers:true}); If you want, I can share you screen via skype and we can go through it. It's all over the internet, this error |
Something new here?? |
I'm actually facing the same issue right now. Everything runs fine in one instance, 400 errors occurred when there are more than one instances running. ps. Mine is running at version 1.0.6. |
+1 |
Okay guys if you want to run cluster, the easiest way is move forward to the library call socketcluster. |
+1 , if I set more than one instances after ELB , I will meet this problem. |
+1 |
Hmm.. I can't make this error again.. (I don't have source for it as some test failed) |
I know whats the problem. All the requests like pooling is everytime calling on the same instance by port. |
Ah.. I didn't clustered in test code. Maybe it's why I can't make it again |
Here is another solution to fixed this problem . However , from most use cases to see , this solution is not good ... The best solution I have come up with is to give each instance (socket server) a different port and store the address of the instance with the number of clients connected to it in redis. Then have the client ask the a separate node app (socket manager) for a socket server address before connecting or reconnecting. The socket manager then picks the socket.io server with the least connections. It's not pretty but it does work and it can be scaled. |
Just to say, had same problem. Then I figured that I am poxying request trough nginx. Added appropriate nginx config, and all was well after that. http://socket.io/docs/using-multiple-nodes/ You need ip_hash in upstream server definition and some headers. |
@dux That worked on Heroku? I don't think we can change the nginx configuration. |
ups, I did not know this is heroku exclusive thread. No, this is vanilla nginx frontend server solution. |
If someone could find solution for HEROKU, please post it here it'll be very helpful :) |
@miklacko after lots of tries and errors I ended with this configuration (bare in mind that I hadn't had the time to test if the messages were shared between the browsers. But what I could test is that I have an stable connection between the Client and the server with a clustered express 4.x and socket 1.x. express.js
server.js (entire file)
index.html (the most important part here)
We need to state to only use I hope today I can test the communication between browsers thought socket/redis. I will share the outcome of that. |
@gonzalodiaz Thank you very much ! I'll try it next week and i will let you know if i'll find some errors or improvements. |
@gonzalodiaz its perfectly working. Only bad thing is that old browsers doesn't support websockets http://caniuse.com/#feat=websockets. Thank you again. |
@miklacko glad to know it worked for you. it worked nicely for me as well :) - Let me know if you find a solution for old browsers. It's not an issue for me right now but it would be nice to have that backup. |
this problem happened when the client use long polling transport , and the server use the cluster mode. use sticky session will be fixed this problem. |
@nauu Heroku doesn't support sticky sessions.
|
@gonzalodiaz does Heroku can running cluster and listen in different port ? if it can do that , u can use the nginx to reverse proxy the request from clients. and use nginx 's sticky session module. |
@nauu No, Heroku doesn't support listening different port. Heroku sets THE port in a env variable and internally it distributes the load between the dynos. It's really a pain. |
So regarding this bug on Heroku, there is no solution if you want to use something like cluster that supports all of socket.io not just web sockets? Thanks! |
You can simulate heroku locally this way: 1- npm install foreman -g This will start 3 instances of your server (app.js) on port 5001, 5002, and 5003 but you can reach them through the reverse proxy on port 3000. Launch this and try to establish a websocket connection and you will see the same issue as on heroku. node-foreman is a good way to simulate heroku's environment locally. The important thing to keep in mind that, although you can access each local instance directly you only have access to the load balancer on Heorku (port 3000 in the example above) |
what is a good solution? |
@ceram1 You solve the problem yet? |
+1 |
@gonzalodiaz Thank you for mentioning |
For those who are having this issue behind a amazon ELB, make sure you enable application-controlled session stickiness (http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-sticky-sessions.html). This solved the problem for me. |
Guys read this article https://devcenter.heroku.com/articles/node-websockets |
for me, it was with nginx ssl http2, and it was polling, so the good config is: const ioSocket = io('', {
// Send auth token on connection, you will need to DI the Auth service above
// 'query': 'token=' + Auth.getToken()
path: '/socket.io',
transports: ['websocket'],
secure: true,
}); |
@p3x-robot I was fixed by this method |
HTTP Response
{"code":1,"message":"Session ID unknown"}
DEBUG=socket.io:*
socket.io:socket joined room 2d1DHsPAtc1Sspm6AAAE +0ms
socket.io:server incoming connection with id rwLW7JMBp6E4TyexAAAG +3s
socket.io:client connecting to namespace / +3s
socket.io:namespace adding socket to nsp / +3s
socket.io:socket socket connected - writing packet +3s
socket.io:socket joining room rwLW7JMBp6E4TyexAAAG +0ms
socket.io:client writing packet {"type":0,"nsp":"/"} +1ms
socket.io:client writing packet {"type":2,"data":["news",{"hello":"world"}],"nsp":"/"} +0ms
socket.io:socket joined room rwLW7JMBp6E4TyexAAAG +1ms
socket.io:server incoming connection with id 03Izy4YOxaYm5-d-AAAH +1s
socket.io:client connecting to namespace / +1s
socket.io:namespace adding socket to nsp / +1s
socket.io:socket socket connected - writing packet +1s
socket.io:socket joining room 03Izy4YOxaYm5-d-AAAH +0ms
socket.io:client writing packet {"type":0,"nsp":"/"} +1ms
socket.io:client writing packet {"type":2,"data":["news",{"hello":"world"}],"nsp":"/"} +0ms
And socket is disconnected immediately
The text was updated successfully, but these errors were encountered: