The Problem
When building Bondly, our peer-to-peer voice and video calling worked fine during local development—but in real-world testing across laptops, mobile browsers, and our Android PWA, calls either failed to connect or connected with dead silence.
1. The Hidden Trap: Dead Public TURN Servers (192.0.2.1)
WebRTC uses ICE (Interactive Connectivity Establishment) to find a network path between peers:
- STUN discovers your public IP/port. On home Wi-Fi or corporate networks with Cone NAT, STUN alone works.
- TURN relays media when peers sit behind strict Symmetric NAT / CGNAT (standard on 4G/5G mobile carriers).
We initially added a popular public fallback (openrelay.metered.ca) when custom TURN credentials weren't configured. Suddenly, even laptop-to-laptop calls stopped working. A quick DNS check revealed why:
Resolve-DnsName openrelay.metered.ca # 100::1 (RFC 6666 Discard-Only Prefix) # 192.0.2.1 (RFC 5737 TEST-NET-1 Blackhole IP) The public host was resolving to a blackhole IP, causing RTCPeerConnection ICE checks to stall. Removing the dead fallback and integrating dynamic Metered TURN credentials (/api/analytics/ice-servers) alongside stun.l.google.com:19302 and stun.cloudflare.com:3478 immediately restored connectivity.
2. Why Mobile Receivers Couldn't Hear Audio
Even after ICE connected, mobile Chrome/Android WebView often stayed silent for two reasons:
- Autoplay Policy vs. Async
ontrack: Tapping "Accept" triggersgetUserMedia()andsetRemoteDescription(), whilepc.ontrackfires later asynchronously. By the timeontracksetsaudio.srcObject, the browser no longer considers it part of the user gesture.- Fix: Pre-create
remoteStreamRef.current = new MediaStream()insidecreatePeerConnection()and callremoteAudioRef.current.play()immediately inside the Accept button click handler whilesrcObjectis already attached.
- Fix: Pre-create
- Video Tracks Inside
<audio>Elements: Passing a combined audio+videoMediaStreaminto<audio>caused mobile browsers to fail silently.- Fix: Isolate audio tracks explicitly:
const audioTracks = rs.getAudioTracks(); remoteAudioRef.current.srcObject = audioTracks.length > 0 ? new MediaStream(audioTracks) : rs; 3. Catching Calls When the App Is Closed
In a PWA/TWA, the OS closes background WebSockets. We added VAPID Web Push (web-push) on the backend: when call:offer arrives for an offline user, we still store the offer in activeCalls and dispatch a high-urgency Web Push (TTL: 45, urgency: 'high') to sw.js, which displays an interactive notification with Answer and Dismiss buttons. Tapping Answer opens /?autoAnswer=1 and auto-accepts the restored offer as soon as Socket.IO reconnects.
Free Engineering & AI Search Diagnostics
Originally published at Kinetic Code Labs.
- Test how ChatGPT, Claude & Perplexity read your site: Run Free AI Vision Simulator
- Audit mobile speed, Core Web Vitals & SEO blockers: Run Free Lighthouse SEO Audit
- Need custom MERN, ERP, or AI automation without middlemen? Book a Free Discovery Call