Laravel Pusher exception: “Illuminate\Broadcasting\BroadcastException”

老子叫甜甜 提交于 2019-12-11 06:01:14

问题


I get "Illuminate\Broadcasting\BroadcastException" when trying to broadcast event. I've checked my .env file - it's set correctly, I'm on localhost so I set 'encrypted' to false aswell, BroadcastServiceProvider is uncommented. Nothing helps.

FULL ERROR IMAGE

bootstrap.js

import Echo from 'laravel-echo'

window.Pusher = require('pusher-js');

window.Echo = new Echo({
   broadcaster: 'pusher',
   key: '***',
   cluster: 'mt1',
   encrypted: false
});

web.php

Route::post('/messages', function() {
$user = Auth::user();

$message = $user->messages()->create([
    'message' => request()->get('message')
]);

broadcast(new MessagePosted($message, $user))->toOthers();

return ['status' => 'OK'];
})->middleware('auth');

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' => false,
   ],
],

回答1:


if your working on localhost try setting your .env file

set

APP_URL=http://localhost

DB_HOST=localhost

and run

php artisan config:cache

hope this helps you :)



来源:https://stackoverflow.com/questions/48492853/laravel-pusher-exception-illuminate-broadcasting-broadcastexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!