##
Issue: Intermittent Audio Failure β LiveKit Using TURN Instead of Direct RTP (SIP β WebRTC)
### Description
We are experiencing intermittent one-way / no-audio issues when connecting SIP calls (via rtpengine + Kamailio) to LiveKit rooms.
In some calls, audio flows correctly. However, in many cases:
- No RTP is received from the LiveKit side
- Calls are terminated after ~20 seconds (likely due to upstream SIP timeout, in this case - WhatsApp)
This behavior started suddenly without any infrastructure changes on our side.
β
### Setup Overview
WhatsApp SIP β Kamailio β rtpengine β LiveKit (Cloud) β Browser
- SIP side codec: PCMU (8kHz)
- WebRTC side codec: Opus (48kHz)
- rtpengine handles transcoding (PCMU β Opus)
LiveKit is cloud-hosted (not self-hosted).
β
### Observed Behavior
From rtpengine-ctl call info:
####
Failing calls
Media (WebRTC side):
172.17.0.4:24998 <> 57.144.41.49:3484
0 packets, 0 bytes, 93 errors
- No RTP received from LiveKit side
- Errors continuously increment
- Call drops after ~20s
β
####
Partially working calls
Media (WebRTC side):
172.17.0.4:25028 <> 57.144.49.49:3484
494 packets, 34 errors
- Some RTP received
- Audio is intermittent
β
####
Working calls
Media (WebRTC side):
172.17.0.4:23068 <> 57.144.49.49:3484
227 packets, 0 errors
- Audio works normally
β
### Key Observation
In all cases, LiveKit is sending media from:
57.144.x.x:3484
This strongly suggests that:
- LiveKit is using a TURN relay
- Instead of a direct ICE host/srflx candidate
β
### Expected Behavior
We expect LiveKit to:
- Prefer direct UDP (host/srflx ICE candidates) when reachable
- Avoid TURN unless strictly necessary
- Even if thatβs not possible, how to reliably use TURN to relay media
β
### Actual Behavior
LiveKit appears to:
- Prefer or fall back to TURN frequently
- Resulting in:
- No RTP flow in some cases
- Intermittent audio in others
β
### Impact
- Calls drop after ~20 seconds due to no media
- Unreliable audio experience
- Production impact on SIP-based calling (WhatsApp integration)
β
### Questions
- Under what conditions does LiveKit Cloud prefer TURN over direct candidates?
- Is there a way to force or prioritize host/srflx candidates?
- Could there be regional TURN routing issues causing intermittent RTP failures?
- Are there any logs or metrics available from LiveKit Cloud to debug ICE candidate selection?
β
### Additional Notes
- No changes were made to:
- Kamailio
- rtpengine
- Network/firewall
- SIP side RTP (WhatsApp β rtpengine) is always stable
- Issue only occurs on WebRTC (LiveKit) side
- Other SIP calls on same infrastructure are working normally
β
### What We Need
- Guidance on ensuring direct RTP path (no TURN)
- Debugging steps for ICE candidate selection in LiveKit Cloud
- Any known issues with TURN reliability on LiveKit Cloud
β
### Optional Debug Info (can provide if needed)
- Full SDP offer/answer
- ICE candidate pairs
- Packet captures (tcpdump)
- rtpengine logs