Reverb has long kept meticulous track of channel subscriptions, but the raw websocket connections themselves were a blind spot. This change introduces a ConnectionRegistry that records every open socket from the moment it connects until the moment it closes, and it rewires the connection count, the ping and prune jobs, and graceful shutdown to consult that registry instead of the channel manager. Upgrading from v1.13.0 requires no configuration changes, but it does change behavior you may have grown used to: unsubscribed sockets now count toward your connection limit, and idle ones finally get cleaned up.
Why some connections were invisible
Until now, Reverb derived its list of open connections from channel subscriptions. The channel manager only knows about clients that have subscribed to at least one channel, so a socket that connected but never subscribed — or had not subscribed yet — was effectively invisible. It was never pinged when idle, never pruned when stale, skipped during graceful shutdown, and excluded from the connection-quota check. In practice this meant leaked memory and file descriptors from zombie sockets, unreliable quota enforcement, and connections that survived a restart they were supposed to be terminated in.
What the registry tracks
Laravel\Reverb\Protocols\Pusher\ConnectionRegistry is a small in-memory singleton, registered automatically by the service provider and keyed by application ID and socket ID. The server adds a connection in open() and removes it first thing in close(). It exposes just four operations:
use Laravel\Reverb\Contracts\ApplicationProvider;
use Laravel\Reverb\Protocols\Pusher\ConnectionRegistry;
$registry = app(ConnectionRegistry::class);
$app = app(ApplicationProvider::class)->findByKey('your-app-key');
$registry->count($app); // every open socket, subscribed or not
foreach ($registry->for($app) as $connection) {
// $connection is a Laravel\Reverb\Contracts\Connection instance
}
The registry lives in the memory of each server process, which is exactly the scope these checks need. Crucially, the ChannelManager contract is unchanged: channels remain the source of truth for subscriptions, presence data, and message routing, while the registry only answers "which sockets are currently open?" Custom channel manager implementations keep working as before.
Connection quotas now count every open socket
ensureWithinConnectionLimit() now compares the registry count against the application's max connections instead of counting subscribed connections. Any socket consumes quota, subscribed or not, and quota is released as soon as the socket closes, because removal from the registry happens before the channel cleanup. If your clients tend to connect without subscribing — dashboards, monitoring scripts, or clients that subscribe late — you may start seeing the 4004 "Application is over connection quota" error in cases where v1.13.0 silently let those sockets through. That is the fix working as intended; raise the max_connections setting for your apps if the workload genuinely needs that many sockets.
Ping, prune, and shutdown now see every socket
The ping and prune jobs iterate the registry, so a client that connects but never subscribes will receive a pusher:ping after the inactivity window and be disconnected with a 4201 "Pong reply not received in time" error if it never responds. Graceful shutdown in reverb:start reads from the registry too, so a restart now disconnects every open socket rather than only subscribed ones.
There is also a subtle improvement to the ConnectionPruned event. The prune job captures the connection's subscriber data — such as the presence-channel user — before unsubscribing it, and always dispatches a ChannelConnection carrying that data:
use Laravel\Reverb\Events\ConnectionPruned;
Event::listen(function (ConnectionPruned $event) {
$event->connection; // a ChannelConnection instance
$event->connection->connection(); // the underlying socket connection
$event->connection->data('user_id'); // subscriber data, e.g. presence user
});
For sockets that were never subscribed, the event still fires — the data payload is simply empty.
Upgrading from v1.13.0
For most applications, upgrading is a matter of pulling the new version and restarting the server. A few things are worth checking:
- Connection limits. Unsubscribed sockets now count toward
max_connections. Audit apps that open bare sockets, and tune the limit if quota errors appear. - Custom
Serveror job overrides. TheServerconstructor gains a third parameter,ConnectionRegistry $connections, and the ping and prune jobs resolve the registry internally. Re-add the dependency if you subclass or replace them. ConnectionPrunedlisteners. The event now carries aChannelConnection; use->connection()for the underlying socket and->data()for subscriber data such as the presence user.
Takeaways
- Every open websocket is tracked from open to close in a per-process
ConnectionRegistrysingleton. - Idle, unsubscribed sockets are now pinged, pruned, counted against the connection limit, and disconnected during graceful shutdown.
- Expect
4004quota errors sooner if clients hold sockets without subscribing; adjustmax_connectionsif needed. ConnectionPrunednow reliably delivers subscriber data (like the presence user) via aChannelConnection.- No configuration changes are required, and the
ChannelManagercontract is untouched.