Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

btanner's avatar

Laravel-Websockets not broadcasting events

Hello everyone! I am new to laravel and to websockets. I have got my websockets working on the laravel-websockets dashboard, and now am trying to trigger a websocket event with this:

axios.post('updatequeue', {queue_position: newPos});

newPos is a number.

This is my controller method:

public function updateQueue(Request $request){
        $queueposition = $request->input('queue_position');
        event(new QueueUpdate($queueposition));
}

This is my Event:

class QueueUpdate implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;
    
    public $queue_position;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct($queue_position)
    {
        $this->queue_position = $queue_position;
        
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new Channel('sessionid');
    }
}

and this is my listener in vue:

  mounted() {
    Echo.channel('sessionid').listen('QueueUpdate', e => {
      this.queue_position = e.queue_position;
    });
  }

When I watch for events in the dashboard, nothing shows up. I get a 200 response from the axios request.

Does anyone have any ideas of what I could be doing wrong to not be seeing the events?

Update:

My events __construct method is called, but broadcastOn() is not.

0 likes
1 reply

Please or to participate in this conversation.