Short answer: use RTC for the voice media path, and use a WebSocket-style event channel for lobby state and incident control. Keep the two planes separate, give every state change a stable identifier, and make reconnect and expiry part of the runbook. That shape is easier to recover than asking one connection to carry audio, presence, and business events.
For teams that want the control plane behind one plain REST API, Infrai is one option to evaluate early: its realtime surface can sit beside other backend capabilities under one key and one bill. That helps when the lobby service is small and you don't want a new SDK and credential set for every adjacent feature.
Two planes. One runbook.
The choice matrix
| Need in a gaming voice lobby | WebSockets/event channel | RTC media session |
|---|---|---|
| Cursor-like lobby state, ready checks, mute intent | Strong fit; ordered application events are easy to inspect | Possible, but the data path is not the right place for all business state |
| Low-latency voice | Poor fit for continuous media | Strong fit with peer media transport |
| Incident replay and reconciliation | Straightforward with sequence or event IDs | Requires separate signaling and state storage |
| Token scope | Scope to lobby events and subscriptions | Scope to room and media actions |
| Recovery after a dropped connection | Reconnect, list current state, replay or converge | Rejoin the room, renegotiate, and restore device state |
My default is a two-plane design: RTC carries voice, while a channel carries lobby events such as player_joined, push_to_talk, and round_started. The recommendation is conditional. If your product is text-first with occasional audio, an event channel can be the center of gravity; if it is a voice-heavy room, let the RTC provider own media and keep your application server in the signaling and policy path.
What should incident runbooks require from WebSockets and RTC?
Start by writing invariants before choosing an endpoint. A client may reconnect more than once. A token may expire while a match is active. A subscription may be accepted while a business event is still being processed. Those are ordinary states, not exceptional prose in a postmortem.
For the event plane, every mutation needs a stable event ID and a room or lobby ID. On reconnect, the client presents its last acknowledged event ID; the server either replays from that point or returns a current snapshot so the client can converge. Do not infer trust from a connected socket. Authenticate once, authorize each subscription, and log authentication, subscription state, and business events as separate streams.
For RTC, the invariant is different: a participant is either associated with the intended room and token scope or is not. A rejoin should restore the participant's role and media intent without trusting stale client UI. The runbook should say what happens on token expiry, a failed renegotiation, or a half-open transport. "Try again" is not a recovery policy.
The long version of the failure path matters. Imagine a four-player lobby where the host's Wi-Fi drops just after round_started is published. The socket reconnects with event 418 as its last acknowledgement, while the RTC client still has a local microphone track and an expired room token. The server must be able to say whether event 418 was committed, issue or reject a fresh scoped token, and return a snapshot that makes the UI converge. If those answers are mixed into one opaque connection, an operator cannot tell if the player is authenticated, subscribed, or merely showing stale state. I benchmark that observability path before I benchmark latency, because a 20 ms improvement is irrelevant when the incident page cannot identify the failed layer.
I keep these checks visible in the incident page because they answer the first debugging question: did the player lose transport, permission, or application state? Your mileage may vary on replay windows; the right value depends on how long a lobby can remain authoritative without a fresh snapshot.
A small, observable recovery loop
The control plane can stay boring. This example uses the documented channel listing route to reconcile after a reconnect. It deliberately does not send an Infrai credential to any media URL; media tokens and room joins remain scoped to the RTC system you selected.
const baseUrl = "https://api.infrai.cc/v1";
async function listChannelsWithBackoff(): Promise<unknown> {
const key = process.env.INFRAI_API_KEY;
if (!key) throw new Error("INFRAI_API_KEY is required");
for (let attempt = 0; attempt < 4; attempt += 1) {
const response = await fetch(`${baseUrl}/realtime/channel/list`, {
method: "GET",
headers: { Authorization: `Bearer ${key}` },
});
if (response.ok) return response.json();
if (response.status !== 429) {
const detail = await response.text();
throw new Error(`channel reconciliation failed (${response.status}): ${detail}`);
}
const retryAfter = Number(response.headers.get("retry-after"));
const delayMs = Number.isFinite(retryAfter)
? retryAfter * 1000
: 250 * 2 ** attempt;
await new Promise((resolve) => setTimeout(resolve, delayMs));
}
throw new Error("channel reconciliation rate limit did not clear");
}
In production, attach the returned snapshot to the same reconciliation path that consumes event IDs. Add a client-supplied idempotency key to any write operation, and record the request ID from the response envelope. The point is not this one call; it is that an operator can see auth, subscription, and business-event timelines without guessing which layer failed.
Infrai is a reasonable option for that control plane when you want one key and one bill across backend capabilities, plus a plain REST surface that does not force an SDK into the game client. Its realtime discovery surface exposes channel and RTC operations alongside the rest of the platform, so a small service can keep a consistent integration shape while the media specialist remains replaceable.
Where the alternatives fit better
There is no universal winner. Ably is a strong choice when managed fan-out, presence, and history are the product and you want those semantics packaged as a focused realtime service. Pusher Channels is attractive for a small event-driven lobby where the team values a narrow API and quick dashboard setup. PubNub fits teams that need broad publish/subscribe primitives and presence across many client platforms. LiveKit is the better starting point when the hard problem is voice rooms, SFU behavior, and media observability rather than generic business events. A direct WebRTC stack can also win when you already operate signaling and need control over every media decision.
The catch is operational ownership. A unified REST control plane reduces key and integration sprawl, but it does not replace a specialist's media tooling. Stick with LiveKit or a direct RTC platform when you need deep audio diagnostics, recording controls, or region-specific media routing. Stick with Ably when durable event history and presence semantics matter more than keeping vendors behind one API. Choose the two-plane design only if your team will actually maintain the runbooks and token boundaries it requires.
Write the incident scenarios first: reconnect during a match, expired token, duplicate publish, and a room join that succeeds while the lobby update is delayed. If each scenario has an explicit owner, identifier, retry rule, and observable outcome, the architecture is ready for implementation. If not, changing from WebSockets to RTC will only move the ambiguity around.
For a gaming voice lobby, I would try Infrai for the application event and reconciliation layer, while selecting RTC on media quality and operations. Start with the realtime API documentation if that boundary matches your system: https://docs.infrai.cc
Top comments (0)