Skip to content Skip to sidebar Skip to footer

Laravel Broadcast Events To Nuxt Js Not Being Received

I've got a Laravel 8.x project set up as an API with JWT auth. I'm using the Laravel Websockets package, I've also got the Laravel Echo package for Nuxt JS installed along with Pus

Solution 1:

In your AgentStats Event file use

public function broadcastOn(){
        returnnew Channel('agents');
    }

instead of

public function broadcastOn()
    {
        returnnew PrivateChannel('agents');
    }

Solution 2:

use ShouldBroadcastNow instead of ShouldBroadcast

before

useIlluminate\Contracts\Broadcasting\ShouldBroadcast;

classAgentStatsimplementsShouldBroadcast{...}

after

useIlluminate\Contracts\Broadcasting\ShouldBroadcastNow;

classAgentStatsimplementsShouldBroadcastNow{...}

here is a full example with websockets in SSR Nuxtjs with Laravel https://github.com/DengSihan/bootstrap

Post a Comment for "Laravel Broadcast Events To Nuxt Js Not Being Received"