Laravel Reverb Issue

Published on Apr 20, 2024
Topics: Laravel, NGINX, Laravel Reverb

I recently had an issue trying to run the new Laravel Reverb.

I kept getting an error like the one below:
Screenshot showing log errors like Laravel Laravel\Reverb\Protocols\Pusher\Http\Controllers\PusherController::__invoke: Argument #2 (Sconnection) must be of type Laravel \Reverb\Servers \Reverb\Connection, Laravel\Reverb\Servers\Reverb\Http\Connection given,

I was able to track down the issue to this line in the Reverb code, checking for an "Upgrade" header.
Screen of source code from Laravel Reverb

Without that header it was not giving back the proper connection. Turns out I had misconfigured NGINX and I was missing that line.

The official docs give this example NGINX config:

server {
    ...
 
    location / {
        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 http://0.0.0.0:8080;
    }
 
    ...
}

I already some NGINX proxy stuff set up in production, and when modifying it to match the example I had simply missed just one line proxy_set_header Upgrade $http_upgrade;. I put the line back in, restart NGINX and all is good.