tux
tux

Reputation: 1287

Laravel Echo Server

I have a Nuxt app on the frontend and Laravel for the API. I have successfully run Laravel echo server on my local machine through an Nginx proxy. When I deployed it on prod I can't get it to work. I have the same config on my local aside from the endpoints. I always get the status 3 on my ws connection.

I am out of idea what to look for or on how to debug the socket connection

nginx config:

location /socket.io/echo/ {
            proxy_pass             http://127.0.0.1:6001;
            proxy_set_header Host  $host;
            proxy_read_timeout     60;
            proxy_connect_timeout  60;
            proxy_redirect         off;

            # Allow the use of websockets
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
    }

enter image description here

Upvotes: 0

Views: 689

Answers (2)

tux
tux

Reputation: 1287

It was a stupid mistake. The server I was working is hosting quite a number of domains. The API was using a different domain name than the nuxt app. Updated the config to point to the API domain name and it is now working well. Thanks!

Upvotes: 0

Uzair Riaz
Uzair Riaz

Reputation: 919

You might need to configure laravel echo to work with SSL. Try configuring it like so:

window.Echo = new Echo({
        broadcaster: 'pusher',
        key: process.env.MIX_PUSHER_APP_KEY,
        wsHost: window.location.hostname,
        wsPort: 6001,
        wssPort: 6001,
        encrypted: true,
        disableStats: true,
        enabledTransports: ['ws', 'wss']
    });

If it doesn't work, kindly confirm what package are you using on the backend side? Is it laravel-websockets? It might need to be configured for SSL as well.

Upvotes: 1

Related Questions