I have an Elastic Beanstalk environment with Application Load Balancer (ALB) setup on Node.js instance which server both REST APIs as well as Socket.IO connections.
When the number of EC2 instances is more than one some of Socket.IO connections are failing with HTTP 400. The same issue is resolved when there is only one instance.
I have also tried enabling sticky sessions in the ALB and have also created a Redis adapter which connects to my Redis instance in ElasticCache.
Unable to figure out what is causing those HTTP 400 errors.
Socket.IO documentation https://socket.io/docs/v2/using-multiple-nodes/
2
Answers
Eventually had to use Network Load Balancer (NLB) which resolved this issue.
After two days of research, I found the solution.
Use transport "websocket" instead of "polling" (default).
Server:
Client: