Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pusher error: Internal server error.. #193

Closed
hazratmilad opened this issue May 9, 2024 · 8 comments
Closed

Pusher error: Internal server error.. #193

hazratmilad opened this issue May 9, 2024 · 8 comments
Assignees

Comments

@hazratmilad
Copy link

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
Copy link
Collaborator

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.

@joedixon joedixon self-assigned this May 10, 2024
@Bangik
Copy link

Bangik commented May 11, 2024

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
Copy link
Author

hazratmilad commented May 12, 2024

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
Copy link
Collaborator

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

protected function parameters(mixed $controller): array
{
$method = match (true) {
$controller instanceof Closure => new ReflectionFunction($controller),
is_string($controller) => count($parts = explode('::', $controller)) > 1 ? new ReflectionMethod(...$parts) : new ReflectionFunction($controller),
! is_array($controller) => new ReflectionMethod($controller, '__invoke'),
is_array($controller) => new ReflectionMethod($controller[0], $controller[1]),
};
$parameters = $method->getParameters();
return array_map(function ($parameter) {
return [
'name' => $parameter->getName(),
'type' => $parameter->getType()->getName(),
'position' => $parameter->getPosition(),
];
}, $parameters);
}

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

@hazratmilad
Copy link
Author

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

protected function parameters(mixed $controller): array
{
$method = match (true) {
$controller instanceof Closure => new ReflectionFunction($controller),
is_string($controller) => count($parts = explode('::', $controller)) > 1 ? new ReflectionMethod(...$parts) : new ReflectionFunction($controller),
! is_array($controller) => new ReflectionMethod($controller, '__invoke'),
is_array($controller) => new ReflectionMethod($controller[0], $controller[1]),
};
$parameters = $method->getParameters();
return array_map(function ($parameter) {
return [
'name' => $parameter->getName(),
'type' => $parameter->getType()->getName(),
'position' => $parameter->getPosition(),
];
}, $parameters);
}

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
Copy link
Collaborator

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
Copy link
Collaborator

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

@hazratmilad
Copy link
Author

@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 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants