I've set up Laravel to use pusher to send events for Laravel Echo, but the events I fire from artisan console don't reach pusher. The events i fire from the pusher debug console are working fine, so the frontend part is okay. Could the vagrant VM interfere with it?
My .env file
QUEUE_DRIVER=sync
...
PUSHER_KEY=<key>
PUSHER_SECRET=<secret>
PUSHER_APP_ID=<app_id>
My broadcasting.php
'default' => env('BROADCAST_DRIVER', 'pusher'),
...
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_KEY'),
'secret' => env('PUSHER_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => 'eu',
'encrypted' => true
],
],
...
]
The event:
class NewMessage implements ShouldBroadcast
{
public function broadcastOn()
{
return [new Channel('chat.'.$this->conversation->id)];
}
}
The event is fired from an Observer class, which observes a models created
event.
public function created(Chat\Message $message)
{
event(new NewMessage($message));
}
The Observer is registered in the AppServiceProvider
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
Message::observe(MessageObserver::class);
}
}
When I run the console command which creates a new message the terminal shows this:
php artisan chat:broadcast asdasd
[2016-12-15 16:26:44] local.INFO: Broadcasting [eventname] on channels [channel] with payload: {...}
Note: most of the names are confidential so I've used placeholders like eventname, channel etc, but I hope the relevant info is there.
Thank you!