question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proxying Websocket connections fails with "Connection closed before receiving a handshake response"

See original GitHub issue

I use BrowserSync configured with the proxy setting to redirect all requests to my local webserver.

When opening the page, i get the following error message in Chrome (Version 42, Arch Linux):

WebSocket connection to 'ws://localhost:3000/ws/791/ori74537/websocket' failed:
Connection closed before receiving a handshake response

Due to this issue in the foxy project, there was indeed no working support for proxying websocket connections: https://github.com/shakyShane/foxy/issues/2

But they pushed a fix in release 10.1.2 which is included as dependency in the current BrowserSync release 2.7.1. I tried using that version, but it did not change anything and i still get the same error.

Do you need more information? Can anyone confirm this issue?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
hutbercommented, Jan 21, 2017

Bit late to the party here, but could I grab an example of the proxy through browsersync by any chance?

1reaction
shakyShanecommented, Jul 26, 2015

Ok, so I have this all fixed now - I need to test in more envs, but I’m pretty sure it’s good to go.

For anyone interested - the problem was relating to the fact that Browsersync in proxy mode tries to use a single server/port to serve the client script, run the web sockets + proxy requests through to your server.

Well it turns out that of course socket.io is handling the upgrade event on the server for Browsersync’s websockets - which means that it was simply not possible to also allow the proxy to pass through other websockets upgrades (for example, your app’s chatroom or whatevs).

The solution is to simple boot a separate server to handle Browsersync’s websocket connections when in proxy mode and pass through all of your own websockets via the proxy (as you’d expect).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Socket.io - failed: Connection closed before receiving a ...
I set up the server on http://jmi.io:3000. As you can see, it works fine with a beautiful long polling channel but now try...
Read more >
WebSocket Connection closed before receiving a handshake ...
I have configured BIMServer to response back to my application and render 3D view loading individual component on viewer(pop-up window). I am ...
Read more >
Proxying Websocket connections fails with ... - GitHub
The solution is to simple boot a separate server to handle Browsersync's websocket connections when in proxy mode and pass through all of...
Read more >
Connection closed before receiving a handshake response
Best Answer. Not sure if this meets your problem completely. But the WebSocket Connection error can be resolved by using the ReconnectingWebSocket script...
Read more >
WebSocket connection to ws:// failed - Google Groups
YES - its the Proxy server failing i just tested directly to the main SIP server and it worked 10 times but 10...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found