WebRTC Architecture & Media Servers · November 19, 2026 · Stan Reshetnyk

WebRTC Signaling Server in Production: Transport, Glare, Reconnects and Scaling

WebRTC Signaling Server in Production: Transport, Glare, Reconnects and Scaling

By Stan Reshetnyk, CTO, Trembit · Last updated 19 November 2026

A WebRTC signaling server is the channel your application defines to carry session descriptions (SDP offers and answers) and ICE candidates between peers, plus the join, leave, authentication and room state around them. WebRTC deliberately leaves it undefined. In a demo it is a short WebSocket relay. In production it has to survive dropped sockets, two offers crossing, a second server, and a deploy while users are mid-call. This guide covers transport choice, the message protocol, reconnect and resume, scaling, security and testing. It is grounded in the specifications, with notes on what our own builds required.

Key takeaways

  • Signaling is yours to design. RFC 9429 §3.1 leaves addressing, retransmission, forking and glare handling to the application.
  • Pick the transport by client and job: WebSocket for interactive apps, HTTP for one-way ingest or playback (WHIP is RFC 9725; WHEP is still a draft), SIP over WebSocket for phone systems, MQTT for devices already on it.
  • Design glare out. Between symmetric peers, use the W3C “perfect negotiation” pattern; between a client and an SFU, let one side make every offer on each peer connection.
  • Socket loss and media failure are separate faults that often arrive together. Resume with a token, replay what was missed, restart ICE only where media failed.
  • Many nodes is a state and fan-out problem. A node holds connections, not rooms; a deploy without draining becomes a reconnect storm.

What this means for the product. When signaling fails, users don’t see an error. They see a call that hangs after a network switch, two people in one room who never see each other, someone who left still shown as present, or every call dropping during a deploy. These failures rarely appear in a demo; they arrive with the second server, the first live deploy and real mobile networks. By then the fix means changing a protocol every client already speaks, which is why these decisions are cheaper before launch.

Evaluating a build or a vendor? Then read our production builds and the FAQ; the middle is engineering reference.

What does a WebRTC signaling server actually do in production?

A production signaling server has six jobs:

  1. Relay SDP offers, answers and ICE candidates between peers, or between each client and the media server.
  2. Authenticate connections and authorize every join.
  3. Track presence: who is in the room, who is reconnecting, who has left.
  4. Issue ICE server configuration, including short-lived TURN credentials.
  5. Hold per-session state so a dropped client can resume.
  6. With an SFU, set up each client’s media session: what to publish, what to receive.

It never carries media. Audio and video travel on the peer connection, often over a different network path. For the basics, see how a WebRTC call is set up.

Some SFUs ship their own signaling; others leave it to you. Our overview of WebRTC media servers compares them, and our P2P, SFU and MCU comparison covers topology.

Which transport should carry signaling: WebSocket, HTTP, SIP over WebSocket or MQTT?

No standard picks one; the transport follows from your clients and what happens after the session starts. Status as of 18 November 2026.

Table 1: Signaling transports compared

TransportStandards statusFitsGives youProduction catch
WebSocketRFC 6455 (2011)Interactive apps: calls, rooms, presenceOne persistent two-way channel with server pushIdle timeouts at load balancers; reconnect and fan-out are yours
HTTP (WHIP, WHEP)WHIP: RFC 9725 (March 2025). WHEP: draft-ietf-wish-whep-05 (October 2026), not an RFCOne-way ingest (WHIP) or playback (WHEP)An SDP offer in an HTTP POSTNo server push. RFC 9725: “SDP renegotiations are not supported in WHIP”, and one MediaStream only
HTTP plus Server-Sent Events or long-pollingNo WebRTC standard; an engineering choiceLow-chatter flows where WebSocket is blockedServer push over plain HTTP; the client sends by POSTTwo channels to correlate; long-polling needs every request of a session routed to the same node
SIP over WebSocketRFC 7118 (2014), subprotocol sipThe far end is a PBX, SIP trunk or contact centerSIP’s call model in the browserSIP’s transaction machinery, and a SIP proxy tier at scale
MQTTMQTT 5.0, OASIS Standard (2019); no WebRTC signaling specDevice fleets already on MQTTBroker publish/subscribe, three QoS levels, retained messagesA broker to operate; topic permissions become your access control

How the decision usually falls:

  • A browser or mobile app with rooms or mid-call changes (screen share, a second camera): WebSocket, because renegotiation needs a channel the server can push on.
  • An encoder publishing to a CDN or SFU: WHIP; our WHIP and WHEP explainer covers both.
  • Calls that must reach a phone system: SIP over WebSocket (RFC 7118) with a SIP server behind it, as in our guide to connecting FreeSWITCH to WebRTC.
  • Devices already on MQTT: MQTT, with the broker part of the signaling tier. Keep SDP out of retained messages, which MQTT 5.0 delivers to future subscribers: a late one would get a stale offer.

How do you design signaling messages so glare, ordering and late candidates don’t break calls?

Glare is two offers crossing: one user starts screen sharing as the other turns on a camera. Each peer is in have-local-offer when the other’s offer arrives, and applying it rolls the local offer back implicitly. A naive app doesn’t crash: both sides answer, then each answer reaches a peer already back in stable and is rejected. Neither new track is negotiated, and a retry can collide again.

Sequence diagram: two WebRTC peers send offers at once; the polite peer rolls back and answers, the impolite peer ignores

The standards leave this to you. RFC 9429, the JSEP specification, says in §3.1: “However, the JSEP implementation is totally decoupled from the actual mechanism by which these offers and answers are communicated to the remote side, including addressing, retransmission, forking, and glare handling. These issues are left entirely up to the application”. It defines no glare procedure of its own.

Between symmetric peers, use perfect negotiation. The W3C WebRTC Recommendation, §10.7 “Perfect Negotiation Example”, calls it “a recommended pattern to manage negotiation transparently”. “The polite peer uses rollback to avoid collision with an incoming offer.” “The impolite peer ignores an incoming offer when this would collide with its own.” The collision test, as the spec’s example writes it:

const readyForOffer = !makingOffer &&    (pc.signalingState == "stable" || isSettingRemoteAnswerPending);const offerCollision = description.type == "offer" && !readyForOffer;ignoreOffer = !polite && offerCollision;

On a collision the impolite peer drops the offer and, as MDN’s walkthrough adds, its candidates. The polite peer applies it; the spec’s comment “SRD rolls back as needed” means setRemoteDescription() undoes the polite peer’s own offer first.

Roles must be fixed per peer pair and survive reconnects and ICE restarts. If they are re-derived and the sides disagree, two polite peers keep rolling back and two impolite peers ignore each other. Let the server assign roles at join and store them in the session record.

Between a client and an SFU, the usual design is one offerer per peer connection. In LiveKit, for example, the client makes every offer on its publishing connection and the server makes every offer on its subscribing one. The other side asks for renegotiation with a signaling message, so glare can’t occur. Check which side your SFU expects to offer.

Ordering across reconnects and nodes. Within one WebSocket, TCP already keeps messages in order; order breaks across a reconnect or when messages cross nodes. Trickle ICE, RFC 8838 §9, requires the signaling protocol to deliver each candidate “exactly once and in the same order it was conveyed”, and says “candidate trickling needs to be correlated to a specific ICE session”, so that “any delayed updates for a previous session can be recognized as such and ignored by the receiving party”. Your protocol therefore needs:

  • Sequence numbers per session and per direction, not per socket, so they survive a reconnect, plus an acknowledgement of the last one received. Replay produces duplicates, so receivers drop any seq already processed.
  • A candidate queue. Per MDN, addIceCandidate() fails with InvalidStateError while remoteDescription is null. Hold early candidates until setRemoteDescription() resolves.
  • The usernameFragment on every candidate, so one from before an ICE restart is recognized as stale and dropped.

An illustrative envelope (not a standard):

{ "type": "candidate", "sessionId": "s-77ab", "seq": 118, "ack": 96,  "payload": { "candidate": "candidate:1 1 UDP ...", "sdpMid": "0",               "sdpMLineIndex": 0, "usernameFragment": "8hhY" } }

What should happen when the signaling connection drops?

Sockets drop for ordinary reasons: a phone moves from Wi-Fi to cellular, a node restarts, a load balancer closes a connection it considers idle. AWS’s Application Load Balancer documentation states: “By default, Elastic Load Balancing sets the idle timeout value for your load balancer to 60 seconds.” Other load balancers differ.

Sequence diagram: socket drops, client resumes with a token, missed messages replay, ICE restart only if media failed

Detect dead peers with an application heartbeat. RFC 6455 §5.5.2 lets a Ping frame serve “as a keepalive”, but browser code can’t send or see one: the WHATWG WebSockets Standard says of Ping and Pong frames, “These are not currently exposed in the API.” A radio drop often produces no close, so a dead socket can look open. Exchange heartbeat messages both ways, well inside the idle timeout; a missed heartbeat starts reconnect on the client and the presence grace window on the server.

Reconnecting is not enough: the server must recognize the participant, and the client must learn what it missed. A resume protocol:

  1. At join, the server issues a resume token and keeps the session record (last acknowledged seq each way, recent messages) in a shared store such as Redis, not in node memory, so any node can resume it.
  2. On close or a missed heartbeat, the client keeps its RTCPeerConnection and reconnects with exponential backoff plus random jitter, capped below the grace window. AWS’s Architecture Blog post “Exponential Backoff and Jitter” gives the reason: “The solution isn’t to remove backoff. It’s to add jitter.”
  3. The client re-authenticates and presents the token with its last received seq. The server replays the gap or, if the gap holds negotiation messages or is too large, sends a snapshot: who is present, their media state, the current negotiation state, never an old offer.
  4. The client checks each peer connection’s connectionState. connected means the ICE/DTLS transport is up, not that media flows; check getStats(). failed means restarting ICE with restartIce(). A network change often breaks socket and media together, and the restart offer goes through the same glare handling as any other.
  5. An expired or unknown token means a fresh join, after the server closes the old participant record, so nobody appears twice.

Presence needs a grace window. On a missed heartbeat or socket close, show the participant as reconnecting, not “left”, and remove them when the window expires; its length is a product decision, and the resume token expires with it. That prevents ghosts who never leave and “joined” notices whenever a phone changes network.

What breaks when you go from one signaling node to many?

With one process, every room is in memory and every peer can find every other. Add a second process behind a load balancer and that fails silently. Plan on connections, not rooms: a room is just a label shared by sockets that may now sit on different machines.

Two signaling nodes with room state in memory, so peers never meet, versus nodes sharing a pub/sub layer and session store

We don’t quote a per-node capacity figure; none holds across message rates, payload sizes, runtimes and instance types. Load-test with realistic join bursts and a forced node restart, and watch memory per connection, CPU and time to resume.

Table 2: What breaks at the second node, and the fix

What users seeCauseFix
Two people in the same room never see each otherRoom state in one process’s memory; peers on different nodesShared room state (Redis or similar), or routing by room id
Offers and candidates sometimes never arriveNo fan-out between nodes, or a fan-out hop that drops messagesA pub/sub layer, with seq/ack replay covering its losses
Connections fail during setup, or work on one node onlyHTTP long-polling behind a load balancer without sticky sessionsSticky sessions, or WebSocket-only transport
Every call’s signaling drops at each deployNodes stopped without drainingDrain first (below) and resume by token
Idle users disconnected at a fixed intervalLoad balancer idle timeout, no heartbeatA heartbeat well inside the timeout
The cluster falls over again right after a restartEvery client reconnects at the same instantClient backoff with jitter; a connection-rate cap on the server

The fan-out hop is not a delivery guarantee. Socket.IO’s docs say that with only WebSocket or WebTransport “sticky sessions are no longer required”, and route cross-node messages through an Adapter, often Redis. Redis documents that “Redis’ Pub/Sub exhibits at-most-once message delivery semantics”. Cover the gap with seq/ack replay from the shared session store, or use a log such as Redis Streams, which supports at-least-once delivery.

Shared state or room affinity is the real design choice. Routing by room id keeps each room in one process, so ordering stays simple, but a node failure takes its rooms down. Shared state lets any node serve any socket, but every message crosses pub/sub and each session’s sequence numbers must come from one place.

Drain for deploys; plan for crashes. To drain, fail the node’s health check so it gets no new connections, tell clients to reconnect after a randomized delay, and exit when empty or at a deadline. A crashed node gives no warning: clients notice through the heartbeat and resume only if session records live outside the node, otherwise via snapshot or fresh join. Media keeps flowing if the media server runs separately; if signaling and the SFU share a process, losing the node loses media too.

Designing this tier before the second server goes up is the work our WebRTC development team does.

How do you secure a WebRTC signaling server?

Match each control to an attacker’s move:

  • Join by guessing or forwarding a room link. A room id is an address, not a credential: authenticate every connection and authorize every join on the server.
  • Reuse a leaked token. The browser WebSocket constructor takes only a URL and optional subprotocols (MDN), so tokens usually travel in the query string or the first message. Query strings land in access logs, so keep tokens short-lived and single-use.
  • Replay a stolen resume token. It is a credential: re-authenticate on resume, bind it to the user and session, make it single-use or rotate it each time, and expire it with the grace window.
  • Open a socket from another site that carries the user’s cookies (cross-site WebSocket hijacking). RFC 6455 §10.2: servers that accept input only from certain sites “SHOULD verify the |Origin| field is an origin they expect”. That stops browser scripts only; per §1.6 a non-browser client “can provide any arbitrary origin string”. Origin checks add to authentication, never replace it.
  • Message a room or peer you were never admitted to. Check every relayed message’s target against the sender’s membership.
  • Flood the server. Rate-limit per connection and cap message size.
  • Harvest addresses from logs. Candidates can carry users’ public IP addresses; log message types, ids and sequence numbers, not payloads.
  • Lift long-lived TURN credentials from a client bundle. Issue short-lived ones over the authenticated channel.

How do you test signaling before production does?

Inject these faults before users do:

Fault you injectExpected result
Drain a node during a deployClients move to other nodes with jitter; no call ends
Kill a node without warningHeartbeat detects it; sessions resume from the shared store; media unaffected if it runs separately
Drop a socket for less than the grace windowShown as reconnecting, then back; no new “joined” event
Drop it for longerRemoved once; the return is a fresh join
Force glare: both sides add a track at the same instantOne negotiation completes; nobody stuck in have-local-offer
Delay the offer so candidates arrive firstCandidates queued, then applied
Replay old messages, or a candidate from before an ICE restartIgnored
Restart every node at onceReconnects spread over time; no second outage

If some of these fail today, or you can’t run them yet, bring the results to the free 30-minute call below.

Our Trickle ICE tester checks which candidates your STUN and TURN configuration actually gathers, and the layer-by-layer diagnosis in our rescue playbook separates SDP, ICE, DTLS, codec and media-server faults.

What does signaling look like in Trembit’s production builds?

Four published builds with a signaling tier and reconnect handling:

  • Pain Cave Live, live group indoor cycling on a Janus SFU. We built the Node.js backend for “session orchestration, participant management, WebRTC signaling, and room lifecycle”, and reconnection logic that preserves ride state and metrics continuity “so riders rejoin without losing their position”.
  • HearSports, live sports audio commentary on Janus. WebSocket channels carry “real-time signaling, stream switching, and sync offset negotiation”. Reconnection and buffer management handle mobile network transitions without losing sync, and a load test of the streaming infrastructure covered thousands of concurrent listeners across dozens of commentary streams.
  • webPRAX Face2Face, a KBV-certified psychotherapy video platform. We designed Node.js signaling, authentication and session management with “strict separation between control plane and media plane”. A stated requirement for the signaling layer was reconnection after network interruptions without breaking the therapeutic flow.
  • Drone video streaming on a custom WebRTC server. We built “custom WebRTC signaling optimized for constrained network environments” and a “reconnection engine resuming streams without operator intervention”.

Together they put a signaling tier into fitness, live audio, regulated telehealth and drone video products, with reconnect logic shipped in three of them. Their case studies don’t record glare handling or signaling capacity figures, so the glare and scaling guidance here rests on the specifications and on library and load-balancer documentation.

These failures are architecture decisions, not bugs to patch one by one. If your product shows them, a WebRTC rescue assessment starts by finding which plane, signaling or media, is failing.

Frequently asked questions

Do I need to build my own WebRTC signaling server, or can I use an open-source one? If signaling only handles join, leave and mute, use what your SFU, open-source framework or CPaaS provider ships. Build your own when signaling carries product logic (ordered bids, consent-gated presence, multi-tenant permissions), when you must control where session metadata is stored, or when you integrate SIP systems or devices. See our build-vs-buy guide for real-time video.

What is glare in WebRTC and how do I stop it? Glare is both peers sending an offer at once. Between symmetric peers, use W3C perfect negotiation with fixed polite and impolite roles; between a client and an SFU, let one side make every offer on each peer connection.

Do I need sticky sessions for a WebRTC signaling server? It depends on the library and transport. Socket.IO’s documentation says they are needed with HTTP long-polling, not with WebSocket-only connections. Either way, keep resume state in a shared store.

How many rooms or users can one signaling server handle? There is no honest universal number. A node holds connections, and its limit depends on message rate, payload size, runtime and instance type. Load-test your own message mix.

Can WebRTC signaling run over MQTT, SIP or plain HTTP? Yes. No specification requires a particular signaling (or signalling) transport. Table 1 compares the options, including WHEP, which is still an IETF draft.

Stan Reshetnyk
Written by Stan Reshetnyk CTO

Related Articles

Ready to start?

Let Us Work Together

Tell us about your project and we'll get back within 24 hours.

Get in Touch