phplaravelproductionlaravel-reverb

Laravel Reverb does not get Events from the worker


when using in Production, my reverb server wont get any events from my queue worker, the client connection is successfull and ping pong is working, but when i fire an event, the reverb server wont recognice it.

My nginx config:

map $http_upgrade $type {
    default "web";
}

server {
    listen 80;
    listen [::]:80;
    server_name mypage.de;

    location /.well-known/acme-challenge/ {
        root /var/www/letsencrypt;
    }

    return 301 $host$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name mypage.de;

    ssl_certificate /etc/letsencrypt/live/mypage.de/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mypage.de/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/mypage.de/chain.pem;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers "ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305";
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 1h;

    root /var/www/mypage/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";

    index index.php;
    charset utf-8;

    location / {
        try_files /nonexistent @$type;
    }

    location @web {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location /app {
        proxy_http_version 1.1;
        proxy_set_header Host $http_host;
        proxy_set_header Scheme $scheme;
        proxy_set_header SERVER_PORT $server_port;
        proxy_set_header REMOTE_ADDR $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_read_timeout 180;
        proxy_send_timeout 180;

        proxy_pass 127.0.0.1:6001;
    }

    location /apps {
        proxy_http_version 1.1;
        proxy_set_header Host $http_host;
        proxy_set_header Scheme $scheme;
        proxy_set_header SERVER_PORT $server_port;
        proxy_set_header REMOTE_ADDR $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";

        proxy_pass 127.0.0.1:6001;
    }

    location = /favicon.ico {
        access_log off; log_not_found off;
    }
    location = /robots.txt {
        access_log off; log_not_found off;
    }

    error_page 404 /index.php;

    location ~ ^/index\.php(/|$) {
        try_files $uri /index.php =404;
        fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_hide_header X-Powered-By;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

my .env:

REVERB_APP_ID=xxxx
REVERB_APP_KEY=xxxx
REVERB_APP_SECRET=xxxx
REVERB_HOST="mypage.de"
REVERB_PORT=443
REVERB_SCHEME=https

REVERB_SERVER_HOST=127.0.0.1
REVERB_SERVER_PORT=6001

VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="${REVERB_HOST}"
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"

On the local dev env everything works fine, events get send to the client and the client js gets executed, on production the worker logs that the event is fired but in the reverb log nothing appears.

EDIT:

local env:

BROADCAST_CONNECTION=reverb
QUEUE_CONNECTION=redis

production env:

BROADCAST_DRIVER=reverb
QUEUE_CONNECTION=redis

EDIT AGAIN: By Posting the broadcast env variables i obviously found my mistake myself, looked thousends of time over every variable, but did not find that in my production env the outdated BROADCAST_DRIVER was set instead of the current correct variable BROADCAST_CONNECTION...

Now i feel dumb..


Solution

  • I believe you are using a different env for production.

    Can you try changing BROADCAST_DRIVER=reverb to BROADCAST_CONNECTION=reverb?

    Make sure to clear your cache, restart your queues, and restart the supervisor/horizon (if there is any configured)

    Thanks.