+ Nginx results in 502 bad gateway

So I was debugging one of my servers today and I was trying to work out for the subdomain I had setup  it just didn't want to load the websockets over the websocket protocol and was giving me the following error in Chromes console:

WebSocket connection to 'ws://' failed: Error during WebSocket handshake: Unexpected response code: 502 

And I kept thinking it was an issue with my Nginx config, I was googling and googling but all the results seemed to point to my configuration being correct. Until I stumbled onto one that suggested looking at  and I was startled to see that websockets didn't work on port 80. This seemed rediculous to me, why can't they be served or accessed on the same port as webpages are transferred on? Any way the solution was simple I just modified the the io.connect() statement to append the port that the application was originally running on to be the port the websocket was created on. This solved the issue as the websocket was now being accessed on .

Benjamin Kaiser

Benjamin Kaiser

Software Engineer working on the SharePoint team at Microsoft. I'm passionate about open source, slurpess, and Jesus.
Gold Coast, Australia

Post Comments