Jason Ayer
Jason Ayer

Reputation: 823

Exception: Illuminate \ Broadcasting \ BroadcastException No message in PusherBroadcaster.php:119

Laravel 5.8

I am new to this whole pusher functionality and I've been following this tutorial and trying it out,

Create Web Notifications Using Laravel and Pusher Channels.

I've followed it step-by-step and when I get to the step to manually test the event by visiting the test url, I receive the following exception:

Illuminate \ Broadcasting \ BroadcastException No message

C:\wamp\www\ares\vendor\laravel\framework\src\Illuminate\Broadcasting\Broadcasters\PusherBroadcaster.php

Here is the code:

    $response = $this->pusher->trigger(
        $this->formatChannels($channels), $event, $payload, $socket, true
    );

    if ((is_array($response) && $response['status'] >= 200 && $response['status'] <= 299)
        || $response === true) {
        return;
    }

    throw new BroadcastException( // <-- Exception at this line
        is_bool($response) ? 'Failed to connect to Pusher.' : $response['body']
    );
}

/**
 * Get the Pusher SDK instance.
 *
 * @return \Pusher\Pusher
 */
public function getPusher()
{
    return $this->pusher;
}
}

I've looked at a few other stack overflow articles which talk about changing encrypted: true to encrypted: false but that does not seem to affect anything.

Upvotes: 3

Views: 10281

Answers (6)

Felix Contreras
Felix Contreras

Reputation: 1

If you launch your project on an online server using the PM2 method, you might encounter HTTP/HTTPS issues. To configure Pusher with a custom port, for example, port 2096/tcp, you need to set it up for your app. This setup requires at least a certificate and private key. Even a self-signed certificate for 127.0.0.1 is mandatory.

Since the service is running under PM2 with SSL certificates configuration, you should try adding Certbot and setting up an Apache server with the domain socket.example.com.

Upvotes: 0

Vahid Montazer
Vahid Montazer

Reputation: 1301

Thanks to dear @Bitart

'useTLS' => true

option solved my issue.

'options' => [
     'cluster' => env('PUSHER_APP_CLUSTER'),
     'useTLS' => true,
]

Upvotes: 0

Franz
Franz

Reputation: 354

If you're working on localhost try setting your .env file.

Set:

APP_URL=http://localhost

DB_HOST=localhost

And run

php artisan config:cache

Upvotes: 4

Bitart
Bitart

Reputation: 83

Worked perfectly up to my Laravel 5.8 version. But encrypted' => true or encrypted' => false did not matter in this case for such Laravel version. But, following PUSHER suggestions, I put to broadcasting: 'useTLS' => true,.

This is the final result to me:

'options' => [
            'cluster' => env('PUSHER_APP_CLUSTER'),
            'encrypted' => true,
            'useTLS' => true,
            'curl_options' => [
                CURLOPT_SSL_VERIFYHOST => 0,
                CURLOPT_SSL_VERIFYPEER => 0,
            ],
        ]

Upvotes: 0

Joseph Joestar
Joseph Joestar

Reputation: 478

I started working on Laravel 4 days ago and I came across this same problem when I was implementing a real-time chat application. After searching for many days, I discovered that this may vary depending on the version of Laravel you are running. If it is 5.8, you can fix this by adding the following code in the pusher.options array of the file config/broadcasting.php:

'curl_options' => [
                CURLOPT_SSL_VERIFYHOST => 0,
                CURLOPT_SSL_VERIFYPEER => 0,
            ],

After adding this , your pusher array in the config/broadcasting.php should look like this.

'pusher' => [
        'driver' => 'pusher',
        'key' => env('PUSHER_APP_KEY'),
        'secret' => env('PUSHER_APP_SECRET'),
        'app_id' => env('PUSHER_APP_ID'),
        'options' => [
            'cluster' => env('PUSHER_APP_CLUSTER'),
            'encrypted' => true,
            'curl_options' => [
                CURLOPT_SSL_VERIFYHOST => 0,
                CURLOPT_SSL_VERIFYPEER => 0,
            ],
        ],
    ],

You can then run php artisan config:cache(which may not be necessary in some cases) and finally run php artisan serve.You can consult your app in the pusher website and see the events you receive after sending your messages. Hope it helps!!

Upvotes: 5

C4pt4inC4nn4bis
C4pt4inC4nn4bis

Reputation: 588

Like i mentioned in a comment before this happens when the whole post goes wrong and wont deliver a response. Thats why the exception in line 116 is raised. I changed it to the domain before!

In my case i followed the code an found the method "createPusherDriver" in "vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastManager.php". At this place i inserted this

var_dump($config['key']);
var_dump($config['secret']);
var_dump( $config['app_id']);
var_dump($config['options']);
exit;

an noticed that my options still listed "host" => "localhost".

I removed those lines an cleared the config cache by executing php artisan config:cache

On next reload my event was fired an logged in the console.

Upvotes: 0

Related Questions