I'm using Laravel Reverb as my WebSocket server, but my agents are custom Go clients (not Laravel Echo). I want to detect when an agent disconnects and mark it as offline, i use de MessageRecived event from reverb to work with al my events,listeners... like this:
<?php
// filepath: /app/Providers/RouteServiceProvider.php
public function boot(): void
{
Event::listen(
MessageReceived::class,
HandlePrivateChannelEvents::class
);
Event::listen(
ChannelCreated::class,
HandleConnectionsReverb::class
);
}
I also tried listening to ChannelRemoved, but when a connection is closed, I only see this log in the terminal:
Connection Closed ...........................................................................1923581.1251234
But I can't capture this as an event in my application code.
When I log the ChannelRemoved event, the channel property is sometimes just an empty array:
[2025-05-20 07:48:05] local.INFO: Received event {"event":{"Laravel\\Reverb\\Events\\ChannelRemoved":{"channel":[]}}},
How can I reliably detect agent disconnections and mark them as offline in Laravel when using Reverb with custom (non-Echo) clients? Is there a way to hook into the low-level connection close event or another recommended approach?
Thanks for all.