alert-honey-38248
10/14/2025, 10:50 AMUser's Phone
↓ (SIP/RTP)
FreeSWITCH (91.98.71.57)
↓ (SIP/RTP Bridge)
LiveKit SIP Trunk (193.122.48.64)
↓ (WebRTC/Room)
Python Voice Agent (LiveKit Agents SDK)
↓ (Audio Frames)
STT Engine (Deepgram/Gladia)
## How Our Code Works
### 1. Call Initiation Flow
1. Backend creates call record in database
2. Backend stores assistant config in Redis (workaround for race condition)
3. Backend calls FreeSWITCH API to originate call
4. FreeSWITCH dials user via SIP provider (Verimor)
5. Simultaneously, FreeSWITCH bridges to LiveKit SIP trunk gateway
6. LiveKit creates a room and SIP participant joins
7. Python agent joins room and waits for SIP participant
### 2. Audio Setup in Python Agent
Our agent uses event-driven audio subscription to handle a known LiveKit Python SDK race condition (GitHub issue #2157):
python
# Step 1: When SIP participant connects WITHOUT audio track yet
# We start the session early and mark the participant as target
self._target_participant_identity = participant.identity
await self.session.start(agent=self.agent_instance, room=self.room)
# Step 2: When audio track is subscribed (track_subscribed event fires)
# We call set_participant() to link the audio stream
room_io.set_participant(participant.identity)
# Step 3: We verify the audio pipeline is ready
# - _audio_input._attached = True (frames will be forwarded)
# - _init_atask.done() = True (LiveKit setup complete)
# - data_ch._closed = False (data channel open)
### 3. Fallback Mechanism
If the track_subscribed event doesn't fire within 5 seconds (known SDK issue), we have a fallback:
python
try:
await asyncio.wait_for(wait_for_setup(), timeout=5.0)
except asyncio.TimeoutError:
# Force call set_participant() anyway
room_io.set_participant(participant.identity)
## The Problem
### Symptoms
When the issue occurs:
- Agent plays greeting message (TTS works)
- STT receives zero audio frames from the user
- Frame monitor detects stall after 1 second
- Recovery attempts (calling set_participant() 3 times) all fail
- Call continues for full duration but agent cannot hear user
### What Logs Show (Failed Call: out-1760438190359-7fxouu)
#### FreeSWITCH Logs (Working Correctly ✅)
# User leg - answered successfully
out-1760438190359-7fxouu 10:36:31 Pre-Answer sofia/external/+905325949930
out-1760438190359-7fxouu 10:36:31 Audio Codec: PCMA/8000
out-1760438190359-7fxouu 10:36:31 AUDIO RTP 91.98.71.57:25478 -> 194.49.126.26:16586
out-1760438190359-7fxouu 10:36:33 Correct audio ip/port confirmed
out-1760438190359-7fxouu 10:36:36 Channel [sofia/external/+905325949930] has been answered
# LiveKit leg - answered successfully
f1d81d49-b521-4653-95d5-77033820b82d 10:36:33 Remote SDP from LiveKit:
c=IN IP4 193.122.48.64
m=audio 55068 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
f1d81d49-b521-4653-95d5-77033820b82d 10:36:33 AUDIO RTP 91.98.71.57:25686 -> 193.122.48.64:55068
f1d81d49-b521-4653-95d5-77033820b82d 10:36:33 Correct audio ip/port confirmed
f1d81d49-b521-4653-95d5-77033820b82d 10:36:33 Channel [sofia/external/2162351882] has been answered
# Bridge active for 80 seconds
out-1760438190359-7fxouu 10:37:50 Hangup [NORMAL_CLEARING]
Analysis: FreeSWITCH successfully:
- Established RTP with user (194.49.126.26:16586)
- Established RTP with LiveKit SIP trunk (193.122.48.64:55068)
- Confirmed bidirectional audio paths
- Both legs answered and bridged
#### Python Agent Logs (Working Correctly ✅)
# SIP participant joined
:telephone_receiver: Track published by sip_freeswitch_uz (SIP: True): kind=KIND_AUDIO
:radio: Track subscribed from sip_freeswitch_uz: kind=KIND_AUDIO
# Event-driven setup triggered
[FIX] :white_check_mark: Audio track TR_AMhwVvdrwLqn6Q is ALREADY subscribed!
[FIX] :dart: Calling set_participant() IMMEDIATELY (track already subscribed)
[FIX] :white_check_mark: set_participant() completed successfully
# Audio pipeline verification - ALL GREEN
[DEBUG-AUDIO-PIPELINE] === RoomIO State Check (WITH audio track) ===
[DEBUG-AUDIO-PIPELINE] :white_check_mark: _audio_input exists: _ParticipantAudioInputStream
[DEBUG-AUDIO-PIPELINE] :white_check_mark: _audio_input._attached = True (frames will be forwarded)
[DEBUG-AUDIO-PIPELINE] _audio_input._participant_identity = sip_freeswitch_uz
[DEBUG-AUDIO-PIPELINE] :white_check_mark: _init_atask exists: done=True
[DEBUG-AUDIO-PIPELINE] :white_check_mark: Audio stream task is running
[DEBUG-AUDIO-PIPELINE] :white_check_mark: Audio data channel is open
# Greeting sent successfully
[DEBUG-RACE-#1] [BEFORE_GREETING] Participant: sip_freeswitch_uz
[DEBUG-RACE-#7] [BEFORE_GREETING] :white_check_mark: linked_participant: sip_freeswitch_uz
[DEBUG-RACE-#1] [AFTER_GREETING] Participant: sip_freeswitch_uz
# But then...
[FRAME-MONITOR] T+1.0s: :rotating_light: STALL DETECTED! No frame activity for 1.0s
[RECOVERY] :rotating_light: ATTEMPT #1: Forcing audio stream recovery...
[RECOVERY] :white_check_mark: Called set_participant() again
[FRAME-MONITOR] T+2.5s: :rotating_light: STALL DETECTED! No frame activity for 1.0s
[RECOVERY] :rotating_light: ATTEMPT #2: Forcing audio stream recovery...
[FRAME-MONITOR] T+4.0s: :rotating_light: STALL DETECTED! No frame activity for 1.0s
[RECOVERY] :rotating_light: ATTEMPT #3: Forcing audio stream recovery...
Analysis: Python agent:
- Successfully detected SIP participant
- Audio track subscribed correctly
- Called set_participant() successfully
- All internal state checks pass (attached, init done, data channel open)
- BUT: No audio frames ever reach the STT engine
#### LiveKit Monitor Logs (Partial Information ⚠️)
Note: Monitor script had a bug (now fixed) where it was joining multiple rooms at once, so we don't have clean logs for this specific call. However, for similar calls we see:
participant connected: agent-AJ_xxx
participant connected: sip_freeswitch_uz
track subscribed: kind=audio, trackID=TR_xxx, participant=sip_freeswitch_uz
connection quality: EXCELLENT
But the monitor doesn't show if RTP packets are actually flowing.
## What We've Tried
### 1. Event-Driven Audio Subscription Fix ✅
Problem: track_subscribed event doesn't fire reliably (LiveKit Python SDK issue #2157)
Solution: Added event-driven subscription with fallback timeout
Result: Now set_participant() is always called (either via event or fallback)
### 2. Audio Pipeline State Verification ✅
Problem: Suspected _attached flag might be False
Solution: Added comprehensive logging of internal LiveKit SDK state
Result: Confirmed _attached=True, _init_atask done, data channel open
### 3. Multiple Recovery Attempts ✅
Problem: Perhaps one-time setup isn't enough
Solution: Frame monitor detects stalls and re-calls set_participant() 3 times
Result: All recovery attempts succeed (no errors) but still no frames
### 4. Fixed LiveKit Monitor Script ✅
Problem: Monitor was joining multiple rooms making logs confusing
Solution: Added head -n 1 to select first room and tracking file to prevent re-joins
Result: Monitor now works correctly but doesn't reveal the audio issue
### 5. Cleanup Handler Race Condition ✅
Problem: Cleanup was hanging on message queue blocking
Solution: Added sentinel value and proper shutdown sequence
Result: Cleanup now works perfectly (separate issue, now fixed)
## Observations
### Pattern
- Approximately 66% success rate (2 out of 3 calls work)
- When it fails, it fails immediately (within 1 second of greeting)
- No correlation with time of day, call duration, or specific phone numbers
- Both successful and failed calls show identical setup logs
### Timing
10:36:30 - Call initiated by backend
10:36:31 - User answers (Pre-Answer from FreeSWITCH)
10:36:32 - Python agent joins room
10:36:33 - LiveKit SIP trunk answers
10:36:33 - SIP participant joins Python agent's room
10:36:33 - Track subscribed, set_participant() called
10:36:34 - Greeting sent
10:36:35 - STALL DETECTED (no frames received)
### Codec Information
- User → FreeSWITCH: PCMA/8000 (G.711 A-law)
- FreeSWITCH → LiveKit: PCMA/8000 (G.711 A-law)
- LiveKit → Python Agent: Should be transcoded to Opus/48000
## Questions
1. Is there a known issue with LiveKit SIP trunk where audio frames from the SIP leg sometimes don't get forwarded to room participants, even though RTP is established?
2. Are there any additional checks we should perform in the Python agent to verify audio is actually flowing from the SIP trunk to the room?
3. Could this be a codec transcoding issue where PCMA → Opus transcoding fails silently in some cases?
4. Is there a way to debug RTP packet flow on the LiveKit side to see if packets are arriving at the SIP trunk but not being forwarded?
5. Should we be subscribing to audio tracks differently for SIP participants versus browser participants?
6. Are there any timing-related issues where calling set_participant() too early (even though _init_atask is done) might cause the audio stream to silently fail?
7. Is there anything in our FreeSWITCH SDP that might be incompatible with LiveKit's expectations? (We're using standard PCMA/8000 with telephone-event/8000)
8. Could this be related to LiveKit's auto-subscribe behavior? We set rtc.TrackSubscribeMode.SUBSCRIBE_MODE_AUDIO_ONLY - should this be different for SIP participants?
## Request
We're stuck at this point. All our checks show the system is working correctly, yet audio frames don't arrive at the STT engine in approximately 1 out of 3 calls. This could be an issue anywhere in the stack:
- Our Python agent code
- LiveKit Python SDK behavior
- LiveKit SIP trunk service
- LiveKit room audio forwarding
- Network/timing issues
- Codec transcoding
- Something we haven't thought of
How can we debug this further to identify the root cause? We're open to any suggestions - adding more logging, trying different LiveKit APIs, adjusting FreeSWITCH configuration, changing our audio subscription approach, or anything else that might help isolate the issue.
## Environment
- LiveKit Agents SDK: 0.11.3 (Python)
- LiveKit Server: Cloud (wespoke-lzp92bdf.ojerusalem1a.production.livekit.cloud)
- FreeSWITCH: 1.10.10 (Docker: drachtio/drachtio-freeswitch-mrf)
- SIP Provider: Verimor (Turkey)
- Codec: PCMA/8000 (G.711 A-law) on SIP side
- Python: 3.13.7
- OS: macOS (agent) + Ubuntu 22.04 (FreeSWITCH)
## Additional Context
We've ruled out:
- Network connectivity (other services work fine)
- FreeSWITCH issues (RTP confirmed on both legs)
- Python agent crashes (no errors or exceptions)
- Resource exhaustion (CPU/memory normal)
- Authentication (calls connect successfully)
The fact that it works sometimes suggests the architecture is fundamentally sound, but there's some intermittent condition causing the audio forwarding to fail.tall-airline-16756
10/14/2025, 10:50 AMtall-airline-16756
10/14/2025, 10:51 AMalert-honey-38248
10/14/2025, 11:44 AM[LIVEKIT-DEBUG] Audio track subscribed - publication.subscribed=True, publication.track=True
[FIX] :dart: Target participant 'sip_freeswitch_uz' SUBSCRIBED to audio track! Now calling set_participant()
[DEBUG-AUDIO-PIPELINE] :white_check_mark: _audio_input._attached = True
[DEBUG-AUDIO-PIPELINE] :white_check_mark: _audio_input._init_atask done
The track subscription completes successfully every time, but the agent still doesn't receive any audio frames from the user.
### 2. Can you provide LiveKit server logs showing audio processing errors?
We don't currently have access to LiveKit cloud server logs. Could you please guide us on how to access these logs? We'd like to see what's happening on the LiveKit SIP trunk side when audio is (or isn't) being forwarded to the room.
Specific call details for your investigation:
- Room Name: call_freeswitch_uz_bRHTnJD9x3ZG
- Call ID: out-1760438190359-7fxouu
- Time: 2025-10-14 103630 - 103750 UTC (1m 20s call)
- SIP Participant: sip_freeswitch_uz
- LiveKit SIP Trunk Endpoint: 193.122.48.64:55068
- Issue: Agent received zero audio frames despite successful track subscription
### 3. Are audio levels visible to other participants in the room?
We added audio level monitoring code to check this. In the latest test call, the monitoring ran for the full 10 seconds without errors:
python
[LIVEKIT-DEBUG] Starting audio level monitoring for sip_freeswitch_uz
[LIVEKIT-DEBUG] Monitoring active for sip_freeswitch_uz (t+0.0s)
[LIVEKIT-DEBUG] Monitoring active for sip_freeswitch_uz (t+0.5s)
...
[LIVEKIT-DEBUG] Audio level monitoring completed for sip_freeswitch_uz
However, we need LiveKit server logs to confirm if audio levels were actually present in the room, or if the issue is at the SIP trunk → room forwarding layer.
---
## New Discovery: Race Condition Between SIP Signaling and Media
We've discovered what we believe is the root cause by analyzing FreeSWITCH logs in detail.
### The Problem: Early SIP 200 OK
Timeline from latest failed call:
| Time | Event |
|------|-------|
| 103631 | User's phone starts ringing |
| 103633 | LiveKit SIP trunk sends 200 OK (answers) |
| 103633 | Python agent joins room and subscribes to tracks |
| 103636 | User actually answers phone (3 seconds later) |
| 103636 | User's audio stream starts flowing |
The race condition:
1. LiveKit SIP trunk answers (200 OK) when the call is routed, not when the user picks up
2. Python agent immediately subscribes to audio tracks after receiving 200 OK
3. At this moment, user's phone is still ringing - no audio stream exists
4. 3 seconds later, user answers and their audio starts flowing
5. Agent has already completed track subscription without user's audio track
6. Agent never receives user audio → STT gets zero frames
### Why This Matches Our 50% Failure Rate
- Works: User answers quickly (1-2 seconds) → tracks subscribe while audio is flowing
- Fails: User answers slowly (3+ seconds) → agent subscribes before user audio exists
- Intermittent: User answer time varies naturally
### FreeSWITCH Confirmation
FreeSWITCH logs show perfect audio routing:
- Both RTP legs confirmed: Correct audio ip/port confirmed
- Codec: PCMA/8000 on both legs
- No packet loss, jitter, or timeout warnings
- Audio is definitely flowing: 91.98.71.57:25686 :left_right_arrow: 193.122.48.64:55068
So audio is reaching LiveKit SIP trunk at 193.122.48.64:55068, but not making it to the Python agent in the room.
---
## Our Questions
### 1. How can we access LiveKit server logs?
We'd like to investigate this issue further on future calls. What's the process for accessing logs from your cloud infrastructure?
### 2. Is this a known SIP signaling vs. media timing issue?
Does LiveKit SIP trunk have any mechanism to:
- Delay sending 200 OK until actual media is ready?
- Re-signal track changes when the remote party actually answers?
- Handle late-joining audio streams in an ongoing call?
### 3. What's the recommended approach for handling this?
We're considering these solutions:
Option A: Re-subscribe on participant events
python
@room.on("participant_connected")
async def on_participant_connected(participant):
# Re-subscribe when new participant joins
for publication in participant.track_publications.values():
if publication.kind == TrackKind.KIND_AUDIO:
await publication.set_subscribed(True)
Option B: Monitor for track republication
python
@room.on("track_published")
async def on_track_published(publication, participant):
# Handle when tracks are published (including late publications)
if publication.kind == TrackKind.KIND_AUDIO:
await publication.set_subscribed(True)
Option C: Delay initial subscription
python
# Wait for media to stabilize before subscribing
await asyncio.sleep(2.0)
Which approach would you recommend? Or is there a better pattern we should follow?
### 4. Should we be using different LiveKit events?
Are we subscribing to tracks at the wrong time? Should we be waiting for different events to indicate that actual media is flowing?
---
## System Details
Our Setup:
- LiveKit Python SDK: v0.11.3
- FreeSWITCH: 1.10.10-release
- Call Flow: User Phone → FreeSWITCH → LiveKit SIP Trunk → LiveKit Room → Python Agent
- Codec: PCMA/8000 from SIP, transcoded to Opus/48000 in room
What We've Tried:
1. ✅ Fixed event-driven track subscription (GitHub issue #2157)
2. ✅ Verified RTP is flowing to LiveKit SIP trunk
3. ✅ Confirmed all agent internal states are correct (_attached, _init_atask, etc.)
4. ✅ Added comprehensive logging and monitoring
5. ✅ Analyzed SIP signaling timing in FreeSWITCH logs
What We Know:
- ✅ Track subscription completes successfully
- ✅ Agent's audio pipeline is initialized correctly
- ✅ RTP audio reaches LiveKit SIP trunk
- ❌ Audio frames never reach Python agent's STT engine
- ❌ Issue occurs in ~50% of calls (timing-dependent)
---
## Request for Guidance
We'd appreciate your help with:
1. How to access LiveKit server logs for deeper investigation
2. Whether our race condition theory is correct
3. The recommended pattern for handling SIP calls with variable answer timing
4. Any LiveKit SIP trunk configuration options we should know about
Thank you for your assistance! We're happy to provide any additional logs or information you need.
---
Generated: 2025-10-14 10:45 UTC
Contact: Backend logs, FreeSWITCH logs, and monitoring data available upon requesttall-airline-16756
10/14/2025, 11:45 AMlog_level: debug in your config.yaml. From there, you’ll be able to access logs through stdout, Docker logs, or system tools like journalctl.
Please don’t hesitate to reach out if you’d like me to guide you through accessing or understanding these logs, or if you need any extra help debugging the SIP signaling and media timing issues. I’m here to help!alert-honey-38248
10/14/2025, 11:49 AM[LIVEKIT-DEBUG] Audio track subscribed - publication.subscribed=True, publication.track=True
[FIX] :dart: Target participant 'sip_freeswitch_uz' SUBSCRIBED to audio track! Now calling set_participant()
[DEBUG-AUDIO-PIPELINE] :white_check_mark: _audio_input._attached = True
[DEBUG-AUDIO-PIPELINE] :white_check_mark: _audio_input._init_atask done
The track subscription completes successfully every time, but the agent still doesn't receive any audio frames from the user.
### 2. Can you provide LiveKit server logs showing audio processing errors?
We don't currently have access to LiveKit cloud server logs. Could you please guide us on how to access these logs? We'd like to see what's happening on the LiveKit SIP trunk side when audio is (or isn't) being forwarded to the room.
Specific call details for your investigation:
- Room Name: call_freeswitch_uz_bRHTnJD9x3ZG
- Call ID: out-1760438190359-7fxouu
- Time: 2025-10-14 103630 - 103750 UTC (1m 20s call)
- SIP Participant: sip_freeswitch_uz
- LiveKit SIP Trunk Endpoint: 193.122.48.64:55068
- Issue: Agent received zero audio frames despite successful track subscription
### 3. Are audio levels visible to other participants in the room?
We added audio level monitoring code to check this. In the latest test call, the monitoring ran for the full 10 seconds without errors:
python
[LIVEKIT-DEBUG] Starting audio level monitoring for sip_freeswitch_uz
[LIVEKIT-DEBUG] Monitoring active for sip_freeswitch_uz (t+0.0s)
[LIVEKIT-DEBUG] Monitoring active for sip_freeswitch_uz (t+0.5s)
...
[LIVEKIT-DEBUG] Audio level monitoring completed for sip_freeswitch_uz
However, we need LiveKit server logs to confirm if audio levels were actually present in the room, or if the issue is at the SIP trunk → room forwarding layer.
---
## The Mystery: Audio Reaches LiveKit SIP Trunk But Not the Room
We've analyzed FreeSWITCH logs in detail and confirmed the audio path up to LiveKit's SIP trunk is perfect.
### FreeSWITCH Analysis
FreeSWITCH logs show perfect audio routing:
- Both RTP legs confirmed: Correct audio ip/port confirmed
- Codec: PCMA/8000 on both legs
- No packet loss, jitter, or timeout warnings
- Audio is definitely flowing: 91.98.71.57:25686 :left_right_arrow: 193.122.48.64:55068
So audio is reaching LiveKit SIP trunk at 193.122.48.64:55068, but not making it to the Python agent in the room.
---
## Our Questions
### 1. Where is the audio being lost?
We've confirmed:
- ✅ RTP audio reaches LiveKit SIP trunk at 193.122.48.64:55068 (FreeSWITCH confirms)
- ✅ SIP participant joins the LiveKit room
- ✅ Python agent subscribes to the audio track successfully
- ❌ BUT: Audio frames never reach the Python agent's STT engine
The gap appears to be between LiveKit SIP trunk receiving RTP and forwarding audio to the room. What could cause this intermittent failure?
### 2. Is this a known issue with SIP trunk audio forwarding?
Have you seen cases where:
- SIP RTP arrives at the trunk endpoint
- Track subscription succeeds
- But audio frames don't forward to subscribed participants in the room?
The issue is truly intermittent (~50% failure rate) and does not appear to be timing-related (fails even when user answers immediately).
### 3. What diagnostics can we add?
Are there specific LiveKit SDK methods or logging we should add to help diagnose this? We're already monitoring:
- Track subscription state
- Audio pipeline internal states
- Track validity
What else would be helpful for troubleshooting?
---
## System Details
Our Setup:
- LiveKit Python SDK: v0.11.3
- FreeSWITCH: 1.10.10-release
- Call Flow: User Phone → FreeSWITCH → LiveKit SIP Trunk → LiveKit Room → Python Agent
- Codec: PCMA/8000 from SIP, transcoded to Opus/48000 in room
What We've Tried:
1. ✅ Fixed event-driven track subscription (GitHub issue #2157)
2. ✅ Verified RTP is flowing to LiveKit SIP trunk
3. ✅ Confirmed all agent internal states are correct (_attached, _init_atask, etc.)
4. ✅ Added comprehensive logging and monitoring
5. ✅ Analyzed SIP signaling timing in FreeSWITCH logs
What We Know:
- ✅ Track subscription completes successfully every time
- ✅ Agent's audio pipeline is initialized correctly
- ✅ RTP audio reaches LiveKit SIP trunk (FreeSWITCH confirms)
- ❌ Audio frames never reach Python agent's STT engine in failed calls
- ❌ Issue occurs intermittently in ~50% of calls
- ❌ NOT timing-related (fails even with immediate answer)
---
## Request for Guidance
We'd appreciate your help with:
1. What could cause intermittent audio forwarding failures between SIP trunk and room participants?
2. Are there any known issues with LiveKit SIP trunk audio handling we should be aware of?
3. What additional diagnostics should we implement to help identify the root cause?
Thank you for your assistance! We're happy to provide any additional logs, run specific tests, or add more instrumentation as needed.
---
Generated: 2025-10-14 10:45 UTC
Contact: Backend logs, FreeSWITCH logs, and monitoring data available upon requesttall-airline-16756
10/14/2025, 11:49 AMalert-honey-38248
10/14/2025, 11:51 AMtall-airline-16756
10/14/2025, 11:52 AMenable_jitter_buffer: true
If you'd like, you can also set how often the jitter buffer is enabled for calls with this option:
enable_jitter_buffer_prob: 1.0 # Always enable
This feature is really helpful because it smooths out any hiccups caused by network delays by buffering incoming RTP packets. Once you’ve made these updates, just restart or reload your LiveKit SIP service to see the changes take effect. If you have any questions along the way, I’m here to help!
Sources: pkg/config/config.go | Secure trunking | LiveKit Docsalert-honey-38248
10/14/2025, 11:53 AMtall-airline-16756
10/14/2025, 11:53 AMalert-honey-38248
10/14/2025, 11:53 AMtall-airline-16756
10/14/2025, 11:54 AMalert-honey-38248
10/14/2025, 11:55 AM193.122.48.64:55068
## 3. ✅ SDP Negotiation - NO ISSUES DETECTED
Status: SDP negotiation succeeds, codecs match
FreeSWITCH logs show successful SDP negotiation:
Local (FreeSWITCH): Offers PCMA, telephone-event on port 25686
Remote (LiveKit): Accepts PCMA/8000 on port 55068
No codec mismatches or missing media lines detected.
## 4. ✅ Signaling - NO DELAYS DETECTED
Status: Clean SIP signaling, no repeated INVITEs
SIP call flow is clean:
- User phone rings at 103631
- LiveKit answers (200 OK) at 103633
- User answers at 103636
- No repeated INVITE attempts or missing ACKs
## 5. ❓ Media Timeout
Status: Need clarification
Could you explain what "media timeout" means in the context of LiveKit SIP trunk?
- Does LiveKit SIP service timeout if there's silence from the remote party?
- What's the default timeout duration?
- Would this show up in LiveKit Cloud call logs?
In our failed calls:
- User is speaking (we can hear them in FreeSWITCH logs)
- RTP is flowing to LiveKit SIP trunk
- But Python agent receives zero audio frames from LiveKit room
This doesn't seem like silence-related timeout since the user is actively speaking.
## 6. ⏳ Continuous Audio Input Test
Status: Can test, but doesn't explain intermittency
You suggested testing with continuous audio input. We can do this, but it doesn't explain why:
- Same setup works 50% of the time
- Failed calls have active user speech (not silence)
- RTP is confirmed flowing to LiveKit SIP trunk even in failures
---
## The Core Mystery
After ruling out all the above, we're still seeing this pattern:
✅ What's Working:
1. RTP successfully reaches LiveKit SIP trunk at 193.122.48.64:55068
2. SIP participant joins LiveKit room successfully
3. Python agent subscribes to audio track successfully
4. All agent internal states are correct (_attached=True, _init_atask done)
❌ What's Failing (50% of calls):
5. Audio frames never reach Python agent's STT engine
6. Agent sees zero audio activity despite RTP flowing to LiveKit SIP trunk
The gap is between LiveKit SIP trunk and room audio forwarding.
---
## Our Questions
### 1. Can you access LiveKit Cloud logs for a specific failed call?
Specific call details:
- Room Name: call_freeswitch_uz_bRHTnJD9x3ZG
- Call ID: out-1760438190359-7fxouu
- Time: 2025-10-14 103630 - 103750 UTC
- SIP Participant: sip_freeswitch_uz
- LiveKit SIP Trunk Endpoint: 193.122.48.64:55068
Could you check the LiveKit server logs for this call to see:
- Did the SIP trunk receive RTP packets?
- Did it successfully decode the audio (PCMA → Opus transcoding)?
- Did it forward audio frames to the room?
- Any errors or warnings during SIP trunk → room forwarding?
### 2. Are there known issues with LiveKit SIP trunk audio forwarding?
Have you seen cases where:
- SIP trunk receives RTP successfully
- Participant joins and subscribes to tracks successfully
- But audio doesn't forward to room participants?
This would explain our intermittent 50% failure rate.
### 3. What additional diagnostics can we add on the Python agent side?
Are there LiveKit SDK methods to:
- Check if audio frames are arriving at the room level (before agent subscription)?
- Monitor RTP packet reception on the SIP participant?
- Detect transcoding failures (PCMA → Opus)?
---
## Additional Context
FreeSWITCH Setup:
- Version: 1.10.10-release
- RTP confirmed on both legs with "Correct audio ip/port confirmed"
- No errors, warnings, or packet loss in logs
Python Agent Setup:
- LiveKit Python SDK v0.11.3
- Connects with AutoSubscribe.AUDIO_ONLY
- Subscribes to tracks after track_subscribed event
- Uses comprehensive logging showing all internal states are correct
Network:
- Server location: Germany (91.98.71.57)
- LiveKit SIP trunk: 193.122.48.64:55068
- No network quality issues observed
---
We appreciate your help investigating this! The issue appears to be specific to LiveKit SIP trunk's audio
forwarding to the room, which is outside our visibility. Any insights from LiveKit server logs would be
extremely valuable.tall-airline-16756
10/14/2025, 11:55 AM