laravel / reverb

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

Pusher error: Internal server error.. #193

Closed hazratmilad closed 2 months ago

hazratmilad commented 2 months ago

Reverb Version

1.0.0

Laravel Version

11.7.0

PHP Version

8.3

Description

after dispatch an event it happens

Illuminate\Broadcasting\BroadcastException

Pusher error: Internal server error..

at vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php:164 160▕ $channels->chunk(100)->each(function ($channels) use ($event, $payload, $parameters) { 161▕ $this->pusher->trigger($channels->toArray(), $event, $payload, $parameters); 162▕ }); 163▕ } catch (ApiErrorException $e) { ➜ 164▕ throw new BroadcastException( 165▕ sprintf('Pusher error: %s.', $e->getMessage()) 166▕ ); 167▕ } 168▕ }

i Here are some links that might help solve this problem:
https://laravel.com/docs/11.x/authentication

  +16 vendor frames 

17 app/Console/Commands/SendGateMessage.php:29 App\Events\GateIoEvent::dispatch("reza taheri ki boodi to akhe?") +13 vendor frames

31 artisan:13 Illuminate\Foundation\Application::handleCommand(Object(Symfony\Component\Console\Input\ArgvInput))

Steps To Reproduce

after dispatch an event it happens

Illuminate\Broadcasting\BroadcastException

Pusher error: Internal server error..

at vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php:164 160▕ $channels->chunk(100)->each(function ($channels) use ($event, $payload, $parameters) { 161▕ $this->pusher->trigger($channels->toArray(), $event, $payload, $parameters); 162▕ }); 163▕ } catch (ApiErrorException $e) { ➜ 164▕ throw new BroadcastException( 165▕ sprintf('Pusher error: %s.', $e->getMessage()) 166▕ ); 167▕ } 168▕ }

i Here are some links that might help solve this problem:
https://laravel.com/docs/11.x/authentication

  +16 vendor frames 

17 app/Console/Commands/SendGateMessage.php:29 App\Events\GateIoEvent::dispatch("reza taheri ki boodi to akhe?") +13 vendor frames

31 artisan:13 Illuminate\Foundation\Application::handleCommand(Object(Symfony\Component\Console\Input\ArgvInput))

joedixon commented 2 months ago

If you run the Reverb server in debug mode, do you see anything in the CLI output when you attempt to dispatch the event? If not, please share your reverb.php config and your REVERB_ prefixed environment variables.

Bangik commented 2 months ago

I have same issue "Pusher error: Internal server error.."

The total number of active users at that time was 76. This error occurred with only 1 user. My Reverb server in different vm from my laravel app

Untitled

Untitled2

Here my reverb.php config

` <?php

return [

/*
|--------------------------------------------------------------------------
| Default Reverb Server
|--------------------------------------------------------------------------
|
| This option controls the default server used by Reverb to handle
| incoming messages as well as broadcasting message to all your
| connected clients. At this time only "reverb" is supported.
|
*/

'default' => env('REVERB_SERVER', 'reverb'),

/*
|--------------------------------------------------------------------------
| Reverb Servers
|--------------------------------------------------------------------------
|
| Here you may define details for each of the supported Reverb servers.
| Each server has its own configuration options that are defined in
| the array below. You should ensure all the options are present.
|
*/

'servers' => [

    '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', 100000000),
        'scaling' => [
            'enabled' => env('REVERB_SCALING_ENABLED', false),
            'channel' => env('REVERB_SCALING_CHANNEL', 'reverb'),
        ],
        'pulse_ingest_interval' => env('REVERB_PULSE_INGEST_INTERVAL', 15),
    ],

],

/*
|--------------------------------------------------------------------------
| Reverb Applications
|--------------------------------------------------------------------------
|
| Here you may define how Reverb applications are managed. If you choose
| to use the "config" provider, you may define an array of apps which
| your server will support, including their connection credentials.
|
*/

'apps' => [

    'provider' => 'config',

    'apps' => [
        [
            'key' => env('REVERB_APP_KEY'),
            'secret' => env('REVERB_APP_SECRET'),
            'app_id' => env('REVERB_APP_ID'),
            'options' => [
                'host' => env('REVERB_HOST'),
                'port' => env('REVERB_PORT', 443),
                'scheme' => env('REVERB_SCHEME', 'https'),
                'useTLS' => env('REVERB_SCHEME', 'https') === 'https',
            ],
            'allowed_origins' => ['*'],
            'ping_interval' => env('REVERB_APP_PING_INTERVAL', 60),
            'max_message_size' => env('REVERB_APP_MAX_MESSAGE_SIZE', 100000000),
        ],
    ],

],

]; `

hazratmilad commented 2 months ago

If you run the Reverb server in debug mode, do you see anything in the CLI output when you attempt to dispatch the event? If not, please share your reverb.php config and your REVERB_ prefixed environment variables.

thank you for your respond

this is what i respond in debug mode :

Screenshot 1403-02-23 at 10 39 09

and this is my config file :

return [

    /*
    |--------------------------------------------------------------------------
    | Default Reverb Server
    |--------------------------------------------------------------------------
    |
    | This option controls the default server used by Reverb to handle
    | incoming messages as well as broadcasting message to all your
    | connected clients. At this time only "reverb" is supported.
    |
    */

    'default' => env('REVERB_SERVER', 'reverb'),

    /*
    |--------------------------------------------------------------------------
    | Reverb Servers
    |--------------------------------------------------------------------------
    |
    | Here you may define details for each of the supported Reverb servers.
    | Each server has its own configuration options that are defined in
    | the array below. You should ensure all the options are present.
    |
    */

    'servers' => [

        '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),
        ],

    ],

    /*
    |--------------------------------------------------------------------------
    | Reverb Applications
    |--------------------------------------------------------------------------
    |
    | Here you may define how Reverb applications are managed. If you choose
    | to use the "config" provider, you may define an array of apps which
    | your server will support, including their connection credentials.
    |
    */

    'apps' => [

        'provider' => 'config',

        'apps' => [
            [
                'key' => env('REVERB_APP_KEY'),
                'secret' => env('REVERB_APP_SECRET'),
                'app_id' => env('REVERB_APP_ID'),
                'options' => [
                    'host' => env('REVERB_HOST'),
                    'port' => env('REVERB_PORT', 443),
                    'scheme' => env('REVERB_SCHEME', 'https'),
                    'useTLS' => env('REVERB_SCHEME', 'https') === 'https',
                ],
                'allowed_origins' => ['*'],
                'ping_interval' => env('REVERB_APP_PING_INTERVAL', 60),
                'max_message_size' => env('REVERB_APP_MAX_MESSAGE_SIZE', 10_000),
            ],
        ],

    ],

];

and this my env file :

BROADCAST_CONNECTION=reverb
QUEUE_CONNECTION=redis

REVERB_APP_ID=371615
REVERB_APP_KEY=ubhqwvdmdjceuih9nysg
REVERB_APP_SECRET=dunq1szayasylx1kovkx
REVERB_HOST="localhost"
REVERB_PORT=8080
REVERB_SCHEME=http

VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="${REVERB_HOST}"
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"
joedixon commented 2 months ago

@hazratmilad it looks like it's failing when trying to get the name of one of your route parameters which happens here: https://github.com/laravel/reverb/blob/f0cee423dce0ed8c8d65dbfdfc531b188627a50d/src/Servers/Reverb/Http/Router.php#L127-L145

You will need to try logging in that file to determine which route is causing the issue.

hazratmilad commented 2 months ago

@hazratmilad it looks like it's failing when trying to get the name of one of your route parameters which happens here:

https://github.com/laravel/reverb/blob/f0cee423dce0ed8c8d65dbfdfc531b188627a50d/src/Servers/Reverb/Http/Router.php#L127-L145

You will need to try logging in that file to determine which route is causing the issue.

this is the result of dumping the array_map :

Screenshot 1403-02-24 at 14 01 55

and both $parameter->getName() and $parameter->getType()->getName(), are working very well

but still have same problem

joedixon commented 2 months ago

Really strange. Can you try dumping the full stack trace here:

https://github.com/laravel/reverb/blob/main/src/Servers/Reverb/Http/Server.php#L59-L66

joedixon commented 2 months ago

@hazratmilad did you manage to resolve this one? If so, what was the issue?

hazratmilad commented 1 month ago

@hazratmilad did you manage to resolve this one? If so, what was the issue?

hi.yes i did it wasn't reverb issue it was in our AppServiceProvider:

$this->app->make('validator')->resolver(function ($translator, $data, $rules, $messages, $attributes) { return new Validator($translator, $data, $rules, $messages, $attributes); });

in this function we are blocking all of attributes that are not in model filleables for more security and it's block our reverb parameters too

handled this :

if (!App::runningInConsole()) { $this->app->make('validator')->resolver(function ($translator, $data, $rules, $messages, $attributes) { return new Validator($translator, $data, $rules, $messages, $attributes); }); } thank you for your cooperating 👍