I set up two EC2 Instances on AWS running behind the Load Balancer, but socket.io breaks when twos instance are running. I assume that as ELB round robins between instances and Socket.io sends requests before updating to Websockets this is causing socket io to break (Session ID unknown). I thought that by using shared session store on Redis , Socket.io would work since all instances would have access to sessions.
I have a small app developed in Node.js(more specifically Sails.js) just for testing. I managed to configure ELB to support Websockets in TCP mode, forwarding the requests to (Phusion Passenger + NGINX) which runs the Sails.js app.
The app uses Redis running on amazon Elasticache for SESSIONS and SOCKETS. If I test both instances separately without ELB, I see that Redis is working for Sockets as the messages are sent and received in both instances.
Is shared sessions enough to make Socket.io work? Or I need sticky sessions in the ELB to forward clients to same instances?
I chose ELB because is easier to add and remove instances dynamically, which is complicated with NGINX(Free) or HAProxy.
Any Ideas?