laravel / reverb

Laravel Reverb provides a real-time WebSocket communication backend for Laravel applications.
https://reverb.laravel.com
MIT License
1.05k stars 76 forks source link

Protocols\Pusher\Http\Controllers\PusherController receveived wrong argument #244

Closed briavers closed 3 weeks ago

briavers commented 3 weeks ago

Reverb Version

1.1.0

Laravel Version

v11.18.1

PHP Version

8.3.x

Description

Locally using herd everything is working, but on staging/production it is not.

my .env


REVERB_APP_ID=799786
REVERB_APP_KEY=someCode
REVERB_APP_SECRET=SomeSecret
REVERB_HOST="myappurl.mycomapny.com"
REVERB_PORT=443
REVERB_SCHEME=https
REVERB_SERVER_PORT=8081

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

my config (should be just the default)

'reverb' => [
            'host' => env('REVERB_SERVER_HOST', '0.0.0.0'),
            'port' => env('REVERB_SERVER_PORT', 8080),
            'hostname' => env('REVERB_HOST'),
            'options' => [
                'tls' => [],
            ],
            'max_request_size' => env('REVERB_MAX_REQUEST_SIZE', 10_000),
            'scaling' => [
                'enabled' => env('REVERB_SCALING_ENABLED', false),
                'channel' => env('REVERB_SCALING_CHANNEL', 'reverb'),
                'server' => [
                    'url' => env('REDIS_URL'),
                    'host' => env('REDIS_HOST', '127.0.0.1'),
                    'port' => env('REDIS_PORT', '6379'),
                    'username' => env('REDIS_USERNAME'),
                    'password' => env('REDIS_PASSWORD'),
                    'database' => env('REDIS_DB', '0'),
                ],
            ],
            'pulse_ingest_interval' => env('REVERB_PULSE_INGEST_INTERVAL', 15),
            'telescope_ingest_interval' => env('REVERB_TELESCOPE_INGEST_INTERVAL', 15),
        ],

My .htaccess in case one

    ProxyPreserveHost On
    ProxyPass "/app" "ws://0.0.0.0:8081/app"
    ProxyPassReverse "/app" "ws://0.0.0.0:8081/app"

my .htaccess in case two


  #reverb
  <IfModule mod_proxy.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/app
    RewriteRule ^(.*)$ http://0.0.0.0:8081/$1 [P]

    <Proxy http://0.0.0.0:8081>
      ProxyPreserveHost On
      ProxyPassReverse /
      ProxyPassReverseCookiePath / /app
    </Proxy>
  </IfModule>

My errors

Case 1

In case 1, my frontend (vue) application can connect to the web socket without issue, using the php artisan reverb:start --debug i see the messages arrive and using inspector I can see the subscriptions to the correct channel. However, when horizon dispatches the event it gets an exception on vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php:164 and receives a 404

Case 2

In case 2 (with the different htaccess file) my Echo cannot connect to the web socket and it gives the following error

 [ERROR] Laravel\Reverb\Protocols\Pusher\Http\Controllers\PusherController::__invoke(): Argument #2 ($connection) must  
         be of type Laravel\Reverb\Servers\Reverb\Connection, Laravel\Reverb\Servers\Reverb\Http\Connection given,      
         called in                                                                                                      
         /var/www/site.com/wwwroot/releases/39/vendor/laravel/reverb/src/Servers/Reverb/Http/Router.php on line 69  

The queue processes the event successful in this case, but that might be because no listeners have been subscribed.

Steps To Reproduce

Change the env en .htaccess config to above variables

briavers commented 3 weeks ago

Placing the following in my htaccess fixed it in case 1, case 2 might still be checked that the correct type of connection is passed

<VirtualHost *:8080> ServerName mysite.com

ServerAlias www.mysite.com

ServerAdmin info@mail.com

reverb

ProxyPreserveHost On ProxyPass "/app" "ws://0.0.0.0:8081/app" ProxyPass "/apps" "ws://0.0.0.0:8081/apps" ProxyPassReverse "/app" "ws://0.0.0.0:8081/app" ProxyPassReverse "/apps" "ws://0.0.0.0:8081/apps"

driesvints commented 3 weeks ago

Hey there,

Can you first please try one of the support channels below? If you can actually identify this as a bug, feel free to open up a new issue with a link to the original one and we'll gladly help you out.

Thanks!