Laravel pusher Illuminate\Broadcasting\BroadcastException 无消息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47990690/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel pusher Illuminate \ Broadcasting \ BroadcastException No message
提问by Mohamed Zayed
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
我'使用Laravel 5.5推杆,使实时通知,从API的通知
后,我所做的配置
在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
Illuminate\Broadcasting\BroadcastException 无消息 错误图像
i followed this video https://www.youtube.com/watch?v=i6Rdkv-DLwk
回答by Mohamed Zayed
i solve my problem by : making the encrypted: false
我通过以下方式解决了我的问题:使加密:false
回答by Sambit Mohapatra
Add curl options to broadcasting.php
将 curl 选项添加到 broadcast.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,
]
],`
回答by Franz
I solved my problem by setting my .env file
我通过设置 .env 文件解决了我的问题
Set:
放:
APP_URL=http://localhost
DB_HOST=localhost
And run
并运行
php artisan config:cache