Error during WebSocket handshake: Unexpected response code: 400
Can't find out a solution, I get this error on the browser console: WebSocket connection to 'ws://.../socket.io/?EIO=2&transport=websocket&sid=p3af7ZNfvogtq6tAAAG0' failed: Error during WebSocket handshake: Unexpected response code: 400.
Hava any advice ?
I am experiencing the exact same issue at the moment, any help?
I am also having this issue since I installed a SSL cert on my domain.
Here is a better description of the issue: http://stackoverflow.com/questions/28025073/error-during-websocket-handshake-unexpected-response-code-400-with-nginx-proxy
Im also having a similar issue connecting with with one of the Android library's. Web sockets won't connect to https through either HAproxy doing ssl termination or letting node do ssl directly. Long polling works fine however
I resolve it by changing the domain to the true IP address:
var socket = io.connect('http://182.92.79.215:3007');
Had the same issue, my app is behind nginx. Making these changes to my Nginx config removed the error.
location / { proxy_pass http://localhost:8080; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; }
This is originally from https://chrislea.com/2013/02/23/proxying-websockets-with-nginx/
Same issue here on production server. Development machines do not show the error.
The strange thing is that the connection is working. I can send messages via WebSockets from the server and the client gets them. I can also see the WebSocket connection being established on the server.
I just get this error in developer tools saying:
WebSocket connection to 'wss://.../socket.io/?EIO=3&transport=websocket&sid=2b_v_BXtbwzl5z2yAAAI' failed: Error during WebSocket handshake: Unexpected response code: 400
I'm using Apache ProxyPass to send connections to node.
Same here - full functional but Error message in dev tools. Somewhere else i read its related to the apache version - using 2.2.14 on this machine.
Make sure you're socket.io connection isn't going through an Amazon Load Balancer. Or if so, do this: http://blog.flux7.com/web-apps-websockets-with-aws-elastic-load-balancing
Same issue here, only in production environment. Websockets seems to work correctly, the application works without problems. But on console log I can see this error.
I'm using Nginx and only one server for node, so it seems to be not a load balancing problem. I was already using the solution suggested by tylercb (with the exception of "proxy_set_header Host $host;") and it is not solving the issue.
also have problem ,but work well....
I had this same issue. Are you using CloudFlare? Currently, only their Enterprise plan supports WebSockets.
Solved for me. It was due to wrong socket.io address in nginx configuration, that was not matching the path using the websocket.
I googled because I got the same problem and I also use nginx. The solution is to add this part
proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host;
into the nginx configuration file like tylercb mentioned.
Worked for me. Thanks.
Got same error directly connecting to my app hosted on Windows Server 2008R2 (no proxy, no IIS). Only dumb intermediate hardware in between.
Work fine after switched host name to ip address, i.e. 127.0.0.1:9000. may caused by httpd ProxyPassReverse
In my case, the issue was as a result of cloudfare not supporting websockets on the free plan. I turned off CloudFare for the domain and it worked.
I just needed to add some Apache rewrite conditions to handle the websockets, more info here: http://stackoverflow.com/a/27534443/2044993
I know this is an old issue, but since it's high on Google search results, but this might help people:
The reason the connection still works even with this error is that socket.io is falling back to AJAX, which is not optimal and you should fix your server configuration.
Btw, this issue should remain closed, it's not a socket.io issue.
@arosenfeld-mentel I keep reading the posts above your comment that "this is not a socket.io issue" but I don't see where anyone says WHAT the issue actually is. I see this myself although, as you say, the connection still seems to work. Any tips would be very gratefully received. Thanks!