h2non/rocky

Websocket connection not going through?

coreyog opened this issue · 1 comments

I'm trying to use rocky in conjunction with live-server. In the TOML I have several routes including the following for the static files that live-server will serve:

["/app/*"]
method = "all"
forward = "http://localhost:8080"

But live-server injects a little javascript so that if it sees that any of the files it serves have been changed on the disk it can notify the browser through a websocket that it needs to reload the page with the new content. However, as soon as I load my page I get the following error (rocky is on port 9000):

WebSocket connection to 'ws://localhost:9000/app//ws' failed: Connection closed before receiving a handshake response

live-server works fine if I hit it directly.

Back in the config file, I tried adding ws = true to the top of the file but then the routing seems to stop working. I get {"message":"Cannot set property 'options' of undefined"} when I hit the same url as before. I've tried variations of

["*/ws"]
ws = true
forward = "http://localhost:8080"

with routes like "/app//ws" and "/app/*/ws" but I still get the same socket connection failure. I've also tried adding ws = true to the "/app/*" route above but no dice.

Do I have a misunderstanding on how to specify the websocket proxy or is something else wrong?

h2non commented

WebSocket traffic proxy is not supported via rocky-cli.
You can fork and add support for that directly at TOML level configuration. It should be simple to do.
Alternatively you can setup your proxy programmatically.