I am trying to follow along with this tutorial: https://www.youtube.com/watch?v=AUlbN_xsdXg which is very straight forward and simple, but unfortunately does not work for me. Based on the comments others do not seem to be having this issue.
This is what I've done so far:
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'), // These env vars have config:cache'd dummy values
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'useTLS' => false,
'encrypted' => false,
'host' => '127.0.0.1',
'port' => '6001',
'scheme' => 'http',
],
],
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class PlaygroundEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new Channel('public.playground.1');
// return new PrivateChannel('channel-name');
}
}
Route::get('/playground', function(){
event(new \App\Events\PlaygroundEvent());
return null;
});
Argument 4 passed to Pusher\Pusher::trigger() must be of the type array, null given, called in [...]vendor\laravel\framework\src\Illuminate\Broadcasting\Broadcasters\PusherBroadcaster.php on line 113
If you search for that error you will find like 2 results that are both unresolved. Not sure where to mention this but the WebSockets Dashboard appears to work fine.
Environment: PHP Version 7.4.5, Windows 10 64, "laravel/framework": "^7.0", "beyondcode/laravel-websockets": "^1.13", "pusher/pusher-php-server": "7.0" and 7.2 while trying to fix.
Since there's so little out there for this error I'm not sure where to go next, except here of course. Any help appreciated, thank you.
Edit: The stacktrace: https://justpaste.it/9lwe3
Try adding a payload to the event:
public function broadcastWith() {
return [
"foo" => "bar"
];
}
Alternatively, upgrading to Laravel 8+ should solve this issue.