Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel pusher Illuminate \ Broadcasting \ BroadcastException No message

I'am using Laravel 5.5 with pusher to make a real time notification , the notification made from the Api
after i made the configuration
in the Api

     public function store(Request $request)
    { 
         $advertising = Advertising::create($request->all()); 
         $admins = \App\Admin::all();
        \Notification::send( $admins, new \App\Notifications\AdvertisingAdded($advertising) );

         return $advertising;
    } 

in AdvertisingAdded

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

use Illuminate\Notifications\Messages\BroadcastMessage;
use App\Advertising;

class AdvertisingAdded extends Notification
{
    use Queueable;

    //-must be public fir pusher
    public $advertising;

    public function __construct(Advertising $advertising)
    {
        $this->advertising = $advertising;
    }


    public function via($notifiable)
    {
        return ['database','broadcast'];
    }


    public function toArray($notifiable)
    {
        return [
            'msg' => 'Advertising '.$this->advertising->title_ar.' is added ',
            'advertising_id' => $this->advertising->id
        ];
    }

    public function toBroadcast($notifiable)
    {
        return new BroadcastMessage([
            'msg' => 'Advertising '.$this->advertising->title_ar.' is added ',
            'advertising_id' => $this->advertising->id
        ]);
    }
}

when i post from postman i get an error

Illuminate \ Broadcasting \ BroadcastException No message error image

i followed this video https://www.youtube.com/watch?v=i6Rdkv-DLwk

like image 673
Mohamed Zayed Avatar asked Dec 27 '17 10:12

Mohamed Zayed


3 Answers

i solve my problem by : making the encrypted: false

like image 120
Mohamed Zayed Avatar answered Nov 09 '22 12:11

Mohamed Zayed


Add curl options to broadcasting.php

`'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,
                    ]
                ],`
like image 30
Sambit Mohapatra Avatar answered Nov 09 '22 11:11

Sambit Mohapatra


I solved this problem. In config/broadcasting.php use this code

'options' => [
'cluster' => 'eu',
'useTLS' => false
],

make useTLS false

like image 1
riksaparadila pasa Avatar answered Nov 09 '22 11:11

riksaparadila pasa