简体   繁体   中英

Express socket.io erroring 404 on websockets

I am using socket.io in my express.js application however it keeps returning 404 from our UAT server when trying to transfer via websockets.

It's worth noting that on my local server everything works fine so I assume it is some kind of configuration on the UAT.

Here is the actual error: WebSocket connection to 'ws://timesheet.hw.s2.hwuat.com/socket.io/?EIO=2&transport=websocket&sid=eUtgUXweLDzSblrjAAE8' failed: Error during WebSocket handshake: Unexpected response code: 400

-- example requests --

Request URL : ws://timesheet.hw.s2.hwuat.com/socket.io/?EIO=2&transport=websocket&sid=AssKCIfT3vTVwmHcAAE4 - fails

Request URL : http://timesheet.hw.s2.hwuat.com/socket.io/?EIO=2&transport=polling&t=1422444487679-3&sid=AssKCIfT3vTVwmHcAAE4 - success

I'm not too good with websockets so I don't really have an idea on where to start looking, has anyone encountered the issue before or can point me in a starting direction of what might be causing this?

I had the same issue when trying to access websockets behind a load balancer. Is your UAT environment using any load balancing? I was using AWS ELB and had to change my balancer from HTTP to TCP since web sockets communicate on TCP, the HTTP listener was unable to route the requests.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM