websocket proxy cannot upgrade websocket connection
See original GitHub issueExpected behavior
HPM should upgrade websocket requests always
Actual behavior
HPM websocket proxy cannot upgrade websocket connections sporadically
Setup
- http-proxy-middleware: 0.17.1
- server: tornado 4.4.1 - Tornado Github
- webpack: 1.13.2
- webpack-dev-server: 1.16.1
proxy middleware configuration
devServer: {
proxy: {
'/hyperguard/websocket/*': {
target: 'ws://localhost:8082',
ws: true
}
}
}
server mounting
def serve_forever(self):
app = self.__make_app()
self.__http_server = HTTPServer(app)
self.__http_server._handle_connection = self._handle_connection
self.__http_server.listen(self.__port, self.__host)
app.ssl_enabled = self.__ssl_options is not None
self.__ioloop.start()
Howto Reproduce
http stream request
GET /hyperguard/websocket HTTP/1.1
Host: localhost:8079
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Sec-WebSocket-Version: 13
origin: http://localhost:8079
Sec-WebSocket-Extensions: permessage-deflate
Sec-WebSocket-Key: yrOcNHCvvVuGgttYgv9nzA==
Connection: keep-alive, Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
http stream response getting this response only sometimes, if not the websocket connection never be established
HTTP/1.1 101 Switching Protocols
upgrade: websocket
connection: Upgrade
sec-websocket-accept: I3u4B7iakSJWk4yLd02hfn+enus=
- that issue also occurs on different platforms (fedora 22, ubuntu 14.04, centos7)
- restarting webpack-dev-server doesnt change anything
Issue Analytics
- State:
- Created 7 years ago
- Comments:20 (4 by maintainers)
Top Results From Across the Web
How to resolve the error: "Could not open websocket connection
How to resolve the error: “Could not open websocket connection: websocket: could not find connection header with token 'upgrade'”.
Read more >Troubleshooting connection issues | Socket.IO
You are trying to reach a plain WebSocket server; The server is not reachable; The client is not compatible with the version of...
Read more >Failed to upgrade websocket connection - Mattermost Forum
Select Reverse Proxy and press OK. 10.In the Add Reverse Proxy Rules dialog, 11.Enter 10.0.0.2:8065 in the Enter the server name or IP...
Read more >java - Cannot connect to Spring WebSocket server due to null ...
Cannot connect to Spring WebSocket server due to null Upgrade Header · Can you use wss instead? · Changing to wss has the...
Read more >Websockets problems — Dataiku DSS 11 documentation
The most common cause of Websocket error is when you connect to DSS through a proxy. Websockets is a fairly recent protocol and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Apologies for commenting on an ancient ticket, but I managed to hit this issue (ws proxy only starts working after manually performing a GET call).
… “http-proxy-middleware”: “^1.0.6”, “react”: “^17.0.1”, “react-scripts”: “4.0.0”, …
I understand that no resolution was found, but does anyone know any workaround (better than manually doing a GET, I mean)?
I had problems with the proxy websocket closing right after connecting. Found out that socket io was closing unhandled requests. If you are using socket io, the fix is to set the destroyUpgrade option to false: