Prompt

How do I debug failed WebRTC connections?

Technology / API Platforms1 observationLast seen Nov 2, 2026

Latest observation

Nov 2, 2026OpenAI APIWeb search: off

Debugging failed WebRTC connections is usually about finding where the setup breaks:

  1. Signaling
  2. ICE candidate gathering / connectivity
  3. DTLS / SRTP negotiation
  4. Media flow once connected

Here’s a practical checklist.


1) Confirm signaling is working

WebRTC does not define signaling, so first verify your app is exchanging:

  • offer
  • answer
  • ICE candidates

Things to check:

  • Does each peer actually receive the SDP?
  • Are ICE candidates being sent in both directions?
  • Are candidates being added only after setRemoteDescription() when required by your flow?

Common signaling bugs

  • Offer/answer SDP never reaches the other peer
  • ICE candidates lost because they arrive before remote description is set
  • Reusing stale SDP/ICE from a previous call
  • Mismatched offer/answer state transitions

2) Inspect RTCPeerConnection state transitions

Log these events and states:

  • signalingState
  • iceConnectionState
  • iceGatheringState
  • connectionState

Example:

pc.oniceconnectionstatechange = () => {
  console.log('iceConnectionState:', pc.iceConnectionState);
};

pc.onconnectionstatechange = () => {
  console.log('connectionState:', pc.connectionState);
};

pc.onsignalingstatechange = () => {
  console.log('signalingState:', pc.signalingState);
};

pc.onicegatheringstatechange = () => {
  console.log('iceGatheringState:', pc.iceGatheringState);
};

Useful meanings

  • new / checking: negotiation underway
  • connected: ICE succeeded
  • completed: ICE fully established
  • failed: ICE could not find a working path
  • disconnected: temporary network issue
  • closed: peer connection closed

If you get stuck in checking or failed, the issue is usually ICE/network related.


3) Gather and examine ICE candidates

Make sure candidates are actually being found:

pc.onicecandidate = (e) => {
  if (e.candidate) {
    console.log('ICE candidate:', e.candidate.candidate);
  } else {
    console.log('ICE gathering complete');
  }
};

What to look for

  • Do you get any candidates at all?
  • Are they only host candidates?
  • Do you get srflx (server reflexive via STUN) or relay (via TURN) candidates?

If you only have host candidates and peers are on different networks/NATs, the connection may fail unless a TURN server is available.


4) Verify STUN/TURN configuration

A very common cause of failure is bad or missing TURN configuration.

STUN

Helps discover public-facing addresses.

Example:

iceServers: [{ urls: 'stun:stun.l.google.com:19302' }]

TURN

Used when direct peer-to-peer connectivity fails.

Example:

iceServers: [
  { urls: 'stun:stun.l.google.com:19302' },
  {
    urls: 'turn:turn.example.com:3478',
    username: 'user',
    credential: 'pass'
  }
]

Common TURN problems

  • Wrong username/password
  • TURN server unreachable from client network
  • UDP blocked, but no TCP/TLS TURN fallback configured
  • TURN server certificates invalid for turns:
  • Incorrect ports/firewall rules

If signaling works but ICE fails, TURN is one of the first things to validate.


5) Use browser WebRTC internals

Chrome / Edge

Go to:

  • chrome://webrtc-internals/

This is extremely useful. It shows:

  • SDP offer/answer
  • ICE candidates
  • connection state changes
  • selected candidate pair
  • stats

Firefox

Use:

  • about:webrtc

These tools often reveal:

  • No candidates gathered
  • STUN requests not returning
  • Candidate pair never selected
  • DTLS handshake failure
  • Media track errors

6) Check SDP for obvious problems

Look at the SDP offer and answer.

Things to verify

  • Both peers include compatible codecs
  • m= sections are present for audio/video/data
  • a=ice-ufrag and a=ice-pwd are present
  • a=fingerprint exists for DTLS
  • a=rtcp-mux is present when expected
  • Direction attributes make sense: sendrecv, sendonly, recvonly, inactive

Common SDP issues

  • SDP munging breaks syntax
  • Codecs removed accidentally
  • BUNDLE or RTCP mux incompatibility
  • Incomplete answer generated by signaling layer

7) Check DTLS/SRTP and certificate issues

If ICE connects but media does not flow, the problem may be in DTLS/SRTP.

Signs:

  • iceConnectionState becomes connected
  • connectionState never reaches connected
  • No media packets received

Possible causes:

  • Certificate mismatch
  • DTLS handshake failure
  • SDP negotiation mismatch
  • Firewall/proxy interference with packets

Browser internals and stats can help show whether DTLS succeeded.


8) Use getStats() to diagnose media and transport

getStats() is one of the best debugging tools.

Example:

const stats = await pc.getStats();
stats.forEach(report => {
  console.log(report.type, report.id, report);
});

Useful stats to inspect

  • candidate-pair
  • local-candidate
  • remote-candidate
  • transport
  • inbound-rtp
  • outbound-rtp
  • track

Key indicators

For candidate-pair:

  • state
  • nominated
  • selected
  • bytesSent
  • bytesReceived

If bytes stay at zero, connectivity or media flow is broken.


9) Test network conditions

WebRTC can fail because of environment, not code.

Check:

  • Corporate firewalls
  • Symmetric NAT
  • UDP blocked
  • VPN interference
  • Mobile networks with strict NAT
  • Browser permissions

Quick test

Try:

  • Same LAN
  • Different networks
  • With and without VPN
  • With TURN only

If it works only on the same network, you likely need TURN.


10) Simplify to isolate the problem

To debug efficiently:

  • Start with audio-only
  • Remove custom SDP munging
  • Use a known-good STUN/TURN config
  • Test with two browsers on the same machine first
  • Then same LAN
  • Then different networks

This narrows down whether the issue is:

  • App logic
  • Signaling
  • ICE
  • Network/firewall
  • Media negotiation

11) Log the exact sequence

A lot of WebRTC bugs are ordering problems. Log these steps:

  • create offer
  • set local description
  • send offer
  • receive answer
  • set remote description
  • send candidate
  • add candidate
  • connection state changes

This often reveals bugs like:

  • calling addIceCandidate() too early
  • setting remote description twice
  • failing to wait for setLocalDescription() to finish

12) Consider browser-specific behavior

Different browsers may behave differently around:

  • Trickle ICE
  • SDP formatting
  • codec preferences
  • mDNS host candidates
  • autoplay restrictions
  • permissions

If it works in one browser but not another, compare:

  • SDPs
  • ICE candidates
  • stats output
  • browser console errors

Quick debugging flow

If a WebRTC connection fails, check in this order:

  1. Did signaling messages arrive?
  2. Are ICE candidates exchanged?
  3. Do any candidates appear?
  4. Does ICE reach connected?
  5. Does DTLS complete?
  6. Do media stats show bytes flowing?
  7. Is TURN configured and working?

Best first tools

  • Browser console logs
  • chrome://webrtc-internals/
  • about:webrtc
  • getStats()
  • TURN server logs
  • Network/firewall inspection

If you want, I can also give you:

  1. a WebRTC debugging checklist,
  2. a sample logging wrapper for RTCPeerConnection, or
  3. help you debug a specific failed connection if you paste your logs / SDP / stats.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.