Skip to main content

How WebRTC Signaling Works

WebRTC itself has no signaling protocol — it only defines how to establish media. The signaling (how you say “call this number” or “I’m ringing”) is up to the application. Here’s how the Telnyx WebRTC SDK does it.

The Signaling Path

Key components:
VSP handles signaling only. B2BUA-RTC handles media only. They are separate systems.

WebSocket Connection

The SDK opens a single persistent WebSocket to rtc.telnyx.com:

What the DNS resolution does

rtc.telnyx.com resolves to the nearest VSP based on DNS-based geo-routing: If the DNS routes to a suboptimal VSP (e.g., an Indian client hitting FR5 instead of CN1), call latency increases. See Configure Network & Firewall for troubleshooting.

Outbound Call Flow

When you call client.newCall(): What the SDK does at each step:
  1. newCall() — Creates a Call object, starts ICE gathering
  2. SIP INVITE — SDK sends invite message over WebSocket, VSP translates to SIP
  3. SDP negotiation — Codec selection (OPUS, PCMU, PCMA), ICE candidates exchanged
  4. Ringing — Remote party’s phone is ringing. call.state === 'ringing'
  5. Answer (200 OK) — Remote party picked up. call.state === 'active'
  6. Media flows — Audio transmitted via WebRTC (separate from signaling)

Inbound Call Flow

When someone calls your WebRTC client: What the SDK does:
  1. Incoming INVITE — VSP receives SIP INVITE, pushes to SDK over WebSocket
  2. callUpdate notificationnotification.call.state === 'ringing'
  3. Your app decides — Call call.answer() or call.hangup()
  4. Answer — SDK sends 200 OK, establishes WebRTC media
  5. Media flows — Two-way audio established

Session Description Protocol (SDP)

During call setup, both sides exchange SDP (Session Description Protocol) to agree on: The SDK handles SDP negotiation automatically. You don’t need to construct SDP manually.

Codec Priority

The SDK’s default codec priority:
  1. OPUS — Best quality, handles packet loss well, variable bitrate
  2. PCMU — G.711μ-law, universal compatibility, 64kbps
  3. PCMA — G.711A-law, European PSTN standard, 64kbps
OPUS is strongly preferred — it handles jitter and packet loss better than G.711, and uses less bandwidth.

WebSocket Reconnection

If the WebSocket drops, the SDK automatically reconnects: See Handle Reconnection for the full reconnection behavior and how to handle it in your app.

Custom Headers

You can pass custom SIP headers in both directions:

Outbound (your app → carrier)

These appear as SIP headers in the INVITE.

Inbound (carrier → your app)

Inbound custom headers are available in the notification:

What Signals What

Mute is a local operation — it stops sending audio from your microphone but doesn’t send any SIP signal. The remote party doesn’t know you’re muted (unless you tell them via your app).

See Also