binary-person / rammerhead

User friendly web proxy powered by testcafe-hammerhead
237 stars 1.77k forks source link

Can't connect to websockets #74

Open kdzapp opened 1 year ago

kdzapp commented 1 year ago

For some reason our website when accessed through rammerhead can't connect to websockets when we host it ourselves, but this seems to be fixed in the closed source version.

Any insight into what's going on / what the fix might be?

binary-person commented 1 year ago

Are you doing nginx proxying? you need to enable websockets for it to work https://www.nginx.com/blog/websocket-nginx/

kdzapp commented 1 year ago

We're using AWS's ALB which supports websockets, under the hood I believe this is exactly what it's doing

kdzapp commented 1 year ago
location / {
    proxy_pass          http://127.0.0.1:8080;
    proxy_http_version  1.1;

    proxy_set_header    Connection          $connection_upgrade;
    proxy_set_header    Upgrade             $http_upgrade;
    proxy_set_header    Host                $host;
    proxy_set_header    X-Real-IP           $remote_addr;
    proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
}

This is what our ec2s have on them

binary-person commented 1 year ago

can you make sure it's the nodejs app that's the issue by hosting a websocket test nodejs app?

kdzapp commented 1 year ago
hammerhead.js:1 WebSocket connection to 'wss://test.sunnyvale.gg/0e2f768f99dc421e80bd027f92a1f2c7!w!s*d1tm91r4ytbt54.cloudfront.net/https://us.sunnyvale.gg' failed:

this is the output, and yeah I can try make a small example (for reference, the websocket connection it's suppose to be making is wss://us.sunnyvale.gg

kdzapp commented 1 year ago

It's possible it has something to do with the websocket connection that's trying to be made is in an iframe?

binary-person commented 1 year ago

no, i meant instead of hosting rammerhead, can you host a small websocket test server in place of rammerhead?