0

I try to fire the event

 public function index()
{
    event(new MessageSent("HELLO"));
    return view('home');
}

and got this error enter image description here

in PusherBroadcaster.php (line 106) at PusherBroadcaster->broadcast(array(object(PrivateChannel)), 'App\Events\MessageSent', array('message' => 'HELLO', 'socket' => null)) in BroadcastEvent.php (line 49)

  • package pusher-php-server was added
  • .ENV variables added
  • in config/broadcasting added app_id, key, secret
  • uncomment BroadcastServiceProvider

What's wrong? Help pls

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175

3 Answers3

0

Have you set Pusher to be your Broadcast Driver under your .env?

kn100
  • 304
  • 1
  • 4
0

i am a bit late, however, I have encountered the same error mine was in the broadcastWith() in the created event which was as follows:

return response()->json([
    'message' => 'hello',
]);

I changed my broadcastWith() function to return the message as an array which fixed the error

public function broadcastWith()
{
    return ['message' => 'hello'];
}

hope it helps

Option
  • 2,605
  • 2
  • 19
  • 29
Elio Tohme
  • 1
  • 1
  • 5
0

I got same problem on localhost but everything's well on public server. Then I try to change "encrypted" => false. Hope you enjoy it. Cheers :)