Definition

What Is a Signaling Server? How WebRTC Calls Get Set Up

Two browsers can stream video to each other directly, but first they need a way to say hello. That go-between is the signaling server.

Signaling server vs media server

Signaling server

Media server (SFU, TURN)

What it carries

Setup messages: SDP, ICE candidates, call state

Audio and video packets

Traffic per call

A few kilobytes

Megabits per second, for the whole call

Typical protocol

WebSockets, HTTP or any message channel

SRTP over UDP, or TCP/TLS fallback

When it is active

Before the call, and on changes

For the whole call

Defined by WebRTC?

No; you choose the format

Yes; standard media protocols

Scaling concern

Many open connections

Bandwidth and CPU

Needed for 1:1 calls?

Always

Only TURN, when a direct path fails

What is a signaling server?

WebRTC lets two browsers or apps send audio, video and data directly to each other. But a browser can't open a connection to a peer it knows nothing about. Before any media flows, the two sides have to agree on three things: that a call is happening, what media and codecs they will use, and which network addresses might reach each other.

Exchanging that information is signaling, and the server that relays it is the signaling server. It is usually a small service that keeps a connection open to each online user.

The WebRTC standards define the content of the messages (SDP and ICE candidates) but deliberately leave the transport and format to you. That is why every WebRTC app has its own signaling design, and why most use WebSockets: both sides need to send messages at any time, with low delay.

How WebRTC signaling works

1. Call setup

The caller tells the callee, through the signaling server, that it wants to start a call. The callee's app rings. This part is pure app logic: invite, accept, decline, busy.

2. Offer and answer

The caller creates an SDP offer: a text description of the media it wants to send and receive, the codecs it supports and its encryption fingerprints. The signaling server forwards it. The callee applies it and replies with an SDP answer. This offer/answer model is defined by JSEP (RFC 9429).

3. ICE candidates

Each side gathers ICE candidates, possible network addresses found locally and through STUN and TURN servers, and sends them through the signaling server as they arrive. This is called trickle ICE.

4. Media flows

ICE finds a working path and media starts flowing directly between peers, or through TURN or an SFU. The signaling server stays involved only for changes: adding screen share, muting video, ending the call or restarting ICE after a network switch.

Signaling server example with WebSockets

A minimal signaling server only relays messages between people in the same room. This one uses Node.js and the ws package:

// server.js: relay every message to the other peers in the room
import { WebSocketServer } from 'ws';
const wss = new WebSocketServer({ port: 8080 });
const rooms = new Map();

wss.on('connection', (ws, req) => {
  const room = new URL(req.url, 'http://localhost').searchParams.get('room');
  if (!rooms.has(room)) rooms.set(room, new Set());
  rooms.get(room).add(ws);
  ws.on('message', (data) => {
    for (const peer of rooms.get(room)) if (peer !== ws) peer.send(data.toString());
  });
  ws.on('close', () => rooms.get(room).delete(ws));
});

In the browser, each peer sends its description and candidates over the socket and applies what it receives:

const ws = new WebSocket('wss://signal.example.com/?room=demo');
const pc = new RTCPeerConnection({ iceServers });
const send = (msg) => ws.send(JSON.stringify(msg));

pc.onicecandidate = ({ candidate }) => candidate && send({ candidate });

ws.onmessage = async ({ data }) => {
  const { description, candidate } = JSON.parse(data);
  if (description) {
    await pc.setRemoteDescription(description);
    if (description.type === 'offer') {
      await pc.setLocalDescription();          // creates the answer
      send({ description: pc.localDescription });
    }
  } else if (candidate) {
    await pc.addIceCandidate(candidate);
  }
};

// Caller: add tracks, then send the offer
await pc.setLocalDescription();
send({ description: pc.localDescription });

Before production, add authentication on connect and check that users can only join rooms they belong to.

Signaling transports compared

  • WebSockets: the common choice. One persistent, two-way connection per user, and the same socket can carry chat messages and presence.

  • HTTP polling or long polling: works where WebSockets are blocked, with more delay and overhead.

  • Server-sent events plus HTTP POST: server-to-client push, with client messages sent as normal requests.

  • Push notifications: not a signaling channel on their own, but needed to wake a mobile app that isn't running so it can receive the call.

Rule of thumb: if your app already keeps a WebSocket open for chat or presence, send call signaling over it. A second connection just for calls adds cost and new ways to fail.

Where signaling servers are used

  • One-to-one calling in chat apps: ringing, accept, decline, busy and missed-call states all travel over signaling before any media.

  • Group calls: clients signal with the SFU to join a room and learn who else is publishing.

  • Mid-call changes: turning on screen share or switching cameras triggers a new offer and answer.

  • Peer-to-peer data: file transfer and multiplayer state over data channels need the same setup.

Limits and pitfalls

  • It doesn't get calls through firewalls. Signaling only exchanges addresses. Connections still fail without TURN.

  • Scaling needs shared state. With several signaling servers behind a load balancer, two peers may connect to different instances. Use a pub/sub layer such as Redis to route messages between them.

  • Glare. If both sides send an offer at the same moment, negotiation breaks. Use a pattern like "perfect negotiation", where one side yields.

  • Ordering and timing. ICE candidates can arrive before the remote description is set. Queue them until it is.

  • Mobile apps sleep. A WebSocket closes when the app is in the background, so incoming calls need push notifications.

  • It is an attack surface. Unauthenticated signaling lets anyone join rooms or flood users with calls. Authenticate and rate-limit it.

Call signaling in CometChat

If your app has chat, you already have the pieces signaling needs: a live connection per user, presence and push notifications. CometChat uses them for calls.

Ringing and call setup handled by the SDK

With the CometChat Calls SDK, initiateCall creates the call and rings the callee. On the web, the incoming call arrives over the Chat SDK's real-time connection, and Android and iOS users are rung through the Push Notifications SDK. Accept, decline, busy and cancel are SDK calls, and the docs say the SDK handles establishing peer connections and managing ICE candidates. You don't write or host a signaling server.

Read the ringing docs · Start building free

Frequently asked questions

Does WebRTC need a signaling server?

Yes. Two peers have to exchange an SDP offer, an SDP answer and ICE candidates before they can connect, and WebRTC leaves that exchange to you. Any channel that can pass messages both ways will do.

Can I use WebSockets for WebRTC signaling?

Yes, and most apps do. A WebSocket gives each user a persistent two-way connection, so either side can send an offer, answer or candidate at any time.

Is a signaling server the same as a STUN or TURN server?

No. The signaling server passes setup messages between peers. STUN helps a peer find its public address, and TURN relays media when a direct connection fails.

Does video go through the signaling server?

No. Only small setup messages do. Audio and video flow directly between peers, or through a TURN relay or an SFU.

What is SDP in WebRTC?

Session Description Protocol. It is the text format of the offer and answer, listing media tracks, codecs, encryption fingerprints and network details for a session.

Related terms