AWS EC2 Behind ELB Always Prints Error Unexpected response code: 400
Problem
Hey guys - Can't seem to find out a solution for this, but when I run my app behind a load balancer, I get this error on the client: [code block] I understand the error, since it's trying to talk to the load balancer and now the EC2 instance (I'm not great with AWS so feel free to offer help on this one!) but what I don't understand is how to make the error not show up! I'd love to fix the root cause but I'm guessing it involves a separate dedicated socket.io server to handle all the real time stuff which I don't have time for at the moment, but could someone please run me through supressing this error? I'm assuming it's falling back to polling, which seems to work just fine (I have the socket connection connected and it fires) but I don't want to launch with a red error in my console. Thanks in advance for any advice you might have!
Error Output
Error during WebSocket handshake: Unexpected response code: 400
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: AWS EC2 Behind ELB Always Prints Error Unexpected response code: 400
I assume you're not using Elastic Beanstalk (the instructions there would be much easier). Go to EC2->Network & Security->Load Balancers Select your load balancer and go to Listeners. Ensure that both the Load Balancer protocol and the Instance Protocol are set to TCP for port 80 and SSL for port 443 rather than HTTP and HTTPS.
Trust Score
7 verifications
- 1
I assume you're not using Elastic Beanstalk (the instructions there would be muc
I assume you're not using Elastic Beanstalk (the instructions there would be much easier).
- 2
Go to EC2->Network & Security->Load Balancers
Go to EC2->Network & Security->Load Balancers
- 3
Select your load balancer and go to Listeners. Ensure that both the Load Balance
Select your load balancer and go to Listeners. Ensure that both the Load Balancer protocol and the Instance Protocol are set to TCP for port 80 and SSL for port 443 rather than HTTP and HTTPS.
Validation
Resolved in socketio/socket.io GitHub issue #1846. Community reactions: 36 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep