Network & Troubleshooting
Audio codecs, bandwidth requirements, firewall configuration, and common issues.
Audio & Codec Details
Supported Codecs
| Codec | Direction | Use case |
|---|---|---|
| Opus | Client ↔ DialStack | WebRTC media path. Wideband (48 kHz), low latency, adaptive bitrate. |
| G.711 μ-law | DialStack ↔ PSTN | PSTN leg. DialStack transcodes between Opus and G.711 transparently. |
The SDP offer from DialStack includes Opus as the preferred codec. You do not need to configure codecs — the browser's WebRTC stack negotiates automatically.
Bandwidth Requirements
| Scenario | Bandwidth (per direction) |
|---|---|
| Opus voice call | 24–40 kbps |
| TURN relay overhead | +10–15 kbps |
| Typical total | ~50–60 kbps up + down |
These are conservative estimates for voice-only calls. Actual bandwidth depends on network conditions — Opus adapts its bitrate dynamically.
Encryption
All WebRTC media is encrypted with DTLS-SRTP (mandatory per the WebRTC specification). The signalling WebSocket uses TLS (WSS). There is no unencrypted path.
ICE/TURN Configuration
WebRTC requires STUN/TURN servers for NAT traversal. The SDK handles this automatically, but if you're building a custom client:
// Fetch ICE server credentials
const response = await fetch('https://api.dialstack.ai/v1/webrtc/ice-servers', {
headers: { Authorization: `Bearer ${userToken}` },
});
const { ice_servers, expires_at } = await response.json();
// Pass to RTCPeerConnection
const pc = new RTCPeerConnection({ iceServers: ice_servers });
TURN credentials are time-limited. Fetch fresh credentials before the expires_at timestamp — typically before each new call.
Network Requirements
Required Connectivity
| Protocol | Destination | Port | Purpose |
|---|---|---|---|
| WSS (TCP) | api.dialstack.ai | 443 | Signalling WebSocket |
| STUN (UDP) | global.stun.twilio.com | 3478 | NAT type discovery |
| TURN (UDP/TCP) | global.turn.twilio.com | 3478 | Media relay (preferred) |
| TURN (TLS/TCP) | global.turn.twilio.com | 443 | Media relay (firewall fallback) |
The exact ICE server URLs and credentials are returned dynamically by the /v1/webrtc/ice-servers endpoint — always use what the API returns rather than hardcoding hostnames.
The signalling WebSocket always uses TCP 443 (standard HTTPS port). Media uses UDP when possible but falls back to TURN over TCP 443 when UDP is blocked — this ensures calls work even behind restrictive corporate firewalls.
How Media Connectivity Works
WebRTC uses ICE (Interactive Connectivity Establishment) to find the best path for audio:
- Direct (host candidate) — local network, lowest latency
- STUN (server-reflexive) — through NAT, still direct peer-to-peer
- TURN (relay) — relayed through DialStack's TURN server, works behind any firewall
The SDK tries all paths simultaneously and uses the best one. If UDP is blocked entirely, TURN over TCP 443 is the last resort — it adds ~20ms latency but is indistinguishable from HTTPS traffic to firewalls.
Enterprise Firewall Configuration
For IT administrators configuring firewalls for DialStack WebRTC:
# Minimum required (signalling + TURN fallback)
Allow TCP 443 outbound to api.dialstack.ai
Allow TCP 443 outbound to global.turn.twilio.com
# Recommended (better audio quality via UDP)
Allow UDP 3478 outbound to global.turn.twilio.com
Allow UDP 3478 outbound to global.stun.twilio.com
TURN over TCP 443 is always available as a fallback. If only TCP 443 is permitted, calls will work but with slightly higher latency.
Troubleshooting
No audio after connecting
Most common cause: UDP is blocked by a firewall. The SDK will fall back to TURN/TCP, but this takes a few seconds. If TURN/TCP is also blocked, media cannot flow.
Verify connectivity: open https://api.dialstack.ai/v1/webrtc/ice-servers in a browser — if this loads, the signalling path is fine and the issue is media.
One-way audio
Typically a symmetric NAT issue. TURN relay resolves this automatically. If one-way audio persists, check that the TURN credentials haven't expired (fetch fresh credentials before each call).
Call drops after ~30 seconds
ICE connectivity check timeout. The media path couldn't be established. Check that at least one of UDP 3478 or TCP 443 to global.turn.twilio.com is reachable.
High latency or choppy audio
Check available bandwidth (50 kbps minimum per direction). Wi-Fi congestion and mobile network transitions are common causes.
Use call.peerConnection.getStats() to inspect WebRTC quality metrics (jitter, packet loss, round-trip time).