Intermittent Error during WebSocket handshake: Unexpected response code: 400 on CloudBees

Michael Neale picture Michael Neale · Jan 25, 2014 · Viewed 30.6k times · Source

I am running a websocket app on CloudBees - and I intermittently see:

Error during WebSocket handshake: Unexpected response code: 400

I have told it to use http 1.1 to allow Upgrades via:

bees app:proxy:update http_version=1.1

And it works, but I sometimes see the error (not always).

Answer

Michael Neale picture Michael Neale · Jan 25, 2014

This is almost certainly due to not using https (SSL). Websocket over plain http is vulnerable to proxies in the middle (often transparent) operating at the http layer breaking the connection.

This is common on cellular networks, or office networks that may use multiple wireless connections with a proxy that spreads the http requests across connections.

The only way to avoid this is to use SSL all the time - this gives websocket the best chance of working.