laravel / reverb

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

Pusher error: error code: 502. #266

Open jessedewild opened 2 days ago

jessedewild commented 2 days ago

Reverb Version

1.1.0

Laravel Version

10.48.20

PHP Version

8.2

Description

I am running Laravel Reverb on my Kubernetes cluster behind Cloudflare. Sometimes, the backend reports the following issue:

Pusher error: error code: 502.

I am using Laravel Echo in my Angular application to connect to Laravel Reverb.

This is the stacktrace:

in /var/www/html/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php line 164
at Illuminate\Broadcasting\Broadcasters\PusherBroadcaster->broadcast()in /var/www/html/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastEvent.php line 92
at Illuminate\Broadcasting\BroadcastEvent->handle()in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php line 36
at Illuminate\Container\BoundMethod->Illuminate\Container\{closure}()in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php line 41
at Illuminate\Container\Util->unwrapIfClosure()in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php line 93
at Illuminate\Container\BoundMethod->callBoundMethod()in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php line 35
at Illuminate\Container\BoundMethod->call()in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php line 662
at Illuminate\Container\Container->call()in /var/www/html/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php line 128
at Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}()in /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php line 144
at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()in /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php line 119
at Illuminate\Pipeline\Pipeline->then()in /var/www/html/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php line 132
at Illuminate\Bus\Dispatcher->dispatchNow()in /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php line 123
at Illuminate\Queue\CallQueuedHandler->Illuminate\Queue\{closure}()in /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php line 144
at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()in /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php line 119
at Illuminate\Pipeline\Pipeline->then()in /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php line 122
at Illuminate\Queue\CallQueuedHandler->dispatchThroughMiddleware()in /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php line 70
at Illuminate\Queue\CallQueuedHandler->call()in /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php line 102
at Illuminate\Queue\Jobs\Job->fire()in /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/Worker.php line 439
at Illuminate\Queue\Worker->process()in /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/Worker.php line 389
at Illuminate\Queue\Worker->runJob()in /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/Worker.php line 176
at Illuminate\Queue\Worker->daemon()in /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php line 137
at Illuminate\Queue\Console\WorkCommand->runWorker()in /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php line 120
at Illuminate\Queue\Console\WorkCommand->handle()in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php line 36
at Illuminate\Container\BoundMethod->Illuminate\Container\{closure}()in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php line 41
at Illuminate\Container\Util->unwrapIfClosure()in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php line 93
at Illuminate\Container\BoundMethod->callBoundMethod()in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php line 35
at Illuminate\Container\BoundMethod->call()in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php line 662
at Illuminate\Container\Container->call()in /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php line 211
at Illuminate\Console\Command->execute()in /var/www/html/vendor/symfony/console/Command/Command.php line 326
at Symfony\Component\Console\Command\Command->run()in /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php line 180
at Illuminate\Console\Command->run()in /var/www/html/vendor/symfony/console/Application.php line 1096
at Symfony\Component\Console\Application->doRunCommand()in /var/www/html/vendor/symfony/console/Application.php line 324
at Symfony\Component\Console\Application->doRun()in /var/www/html/vendor/symfony/console/Application.php line 175
at Symfony\Component\Console\Application->run()in /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php line 201
at Illuminate\Foundation\Console\Kernel->handle()in /var/www/html/artisan line 35

Steps To Reproduce

Run a broadcasting event.

crynobone commented 2 days ago

Can you share the full errors?

https://github.com/laravel/framework/blob/646520ad682d98b5211c6e26092259cfbe130b5c/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php#L163-L166 Indicate that it unable to broadcast the event, this feels like a usage issue.

jessedewild commented 1 day ago

Is it possible to set a different REVERB_HOST for internal and the external? For example, I have set it to:

ws.jessedewild.com

But I am hosting it on a Kubernetes server, which (for example) uses the internal IP 10.0.0.1.

In the reverb.php and broadcasting.php you can set the 'REVERB_HOST'

joedixon commented 16 hours ago

In broadcasting.php, you should set it to the location you need your app to broadcast your messages to. In reverb.php, it's used to set the hostname of the Reverb server.