Home > Blockchain >  Websockets fail in production on my node server hosted on EC2 using nginx. Any tips on how to debug
Websockets fail in production on my node server hosted on EC2 using nginx. Any tips on how to debug

Time:10-08

I have been struggling with getting my websockets to work for a livestreaming application I am building. The app is built using the PERN stack and I am using Postman testing production ws error displayed in the console in chrome EC2 inbound rules EC2 outbound rules

CodePudding user response:

So I did end up getting it to work after a lot of trial and error. The only thing I really changed was my nginx configuration and the port that my websockets were on. I changed the port from 8080 to 3001 for the websockets.

Also here is my updated nginx with the changes I made.

        location /websocket {
            proxy_pass http://ohmystream.xyz:3001;
            proxy_redirect     off;
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   Upgrade $http_upgrade;
            proxy_set_header   Connection "upgrade";
        }
  • Related