I try to test pusher with my application , connection is setup succefuly but pusher can't listen my app events.
I am using laravel 7
broadcasting.php
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => 'ap2',
'encrypted' => true,
'useTLS' => true,
// 'curl_options' => [
// CURLOPT_SSL_VERIFYHOST => 0,
// CURLOPT_SSL_VERIFYPEER => 0,
// ],
],
],
.env file
APP_URL=http://localhost
DB_HOST=localhost
BROADCAST_DRIVER=pusher
PUSHER_APP_ID=XXXXX
PUSHER_APP_KEY=XXXXX
PUSHER_APP_SECRET=XXXXX
PUSHER_APP_CLUSTER=ap2
EventClass
class LikeEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $id;
public $type;
public function __construct($id,$type)
{
$this->id = $id;
$this->type = $type;
}
public function broadcastOn()
{
//return new PrivateChannel('likeChannel'); //I try both
return new Channel('likeChannel');
}
public function broadcastAs()
{
return 'LikeEvent';
}
}
channels.php
Broadcast::channel('likeChannel', function () {
return true;
});
I try to call event in controller by
broadcast(new LikeEvent($reply->id,1))->toOthers();
//broadcast(new LikeEvent($reply->id,1));
//broadcast(new TestEvent("hello pusher"));
//event(new LikeEvent($reply->id,1));
it always throw BroadcastException
"message": "",
"exception": "Illuminate\\Broadcasting\\BroadcastException",
"file": "C:\\wamp64\\www\\rtforum.test\\vendor\\laravel\\framework\\src\\Illuminate\\Broadcasting\\Broadcasters\\PusherBroadcaster.php",
"line": 121,