Core issue: :point_right: SIP call from Twilio is ...
# ask-ai
a
Core issue: πŸ‘‰ SIP call from Twilio is accepted by LiveKit SIP, but the agent/bot is not bridging into the assigned LiveKit room. on the Twilio logs it shows 486 busy here. No livekit room created as well -Livekit Server and sip server setup on same folder in vps ec2 (ubuntu 22.04) -python bot (telephony_agent) running through vs code with same livekit server credential and showing registered. -Twilio SIP trunk configured and calls reach the LiveKit SIP server. -Inbound rule and dispatch rule have been created under sip folder linked to docker-compose.yaml file. Inbound-trunk.json { "trunk": { "name": "My trunk", "numbers": ["+18568306327"] } } β”‚ SipTrunkID β”‚ Name β”‚ Numbers β”‚ AllowedAddresses β”‚ AllowedNumbers β”‚ Authentication β”‚ Encryption β”‚ Headers β”‚ Metadata β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ ST_wHMxVZ3EDxQy β”‚ My trunk β”‚ +18568306327 β”‚ β”‚ β”‚ β”‚ DISABLE β”‚ β”‚ β”‚ ----------------- Dispatch-rule.json { "dispatchRule": { "name": "My Dispatch Rule", "trunkIds": [ "ST_wHMxVZ3EDxQy" ], "rule": { "dispatchRuleIndividual": { "roomPrefix": "call+" } }, "roomConfig": { "agents": [ { "agentName": "telephony_agent" } ] } } } β”‚ SipDispatchRuleID β”‚ Name β”‚ SipTrunks β”‚ Type β”‚ RoomName β”‚ Pin β”‚ Attributes β”‚ Agents β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ SDR_NbeMmr9yR8T5 β”‚ My Dispatch Rule β”‚ ST_wHMxVZ3EDxQy β”‚ Individual (Caller) β”‚ call+_<caller>_<random> β”‚ β”‚ map[] β”‚ telephony_agent β”‚ Sharing sip server logs 2025-09-06T134328.039Z INFO sip sip/inbound.go:801 Inbound call closed {"nodeID": "NE_amJpuZhKV8v3", "callID": "SCL_9qLnowY53iB6", "fromIP": "54.172.60.2", "toIP": "livekit.mjreg.site:5060", "fromHost": "pstn.twilio.com", "fromUser": "+13104007909", "toHost": "livekit.mjreg.site", "toUser": "+18568306327", "sipTag": "94102190_c3356d0b_8d93b6ff-69e7-449e-b0d6-ba4acbfb9399", "sipCallID": "df52019a2a498c827e32b8adeda32ca2@0.0.0.0", "twilioAccSID": "AC3c2ec0a3fd5730f5e9757b86e29dd6a7", "twilioCallSID": "CA6fd872a526dd10e4c7a2f731d83338d5", "sipTrunk": "ST_wHMxVZ3EDxQy", "jitterBuf": false, "sipTrunk": "ST_wHMxVZ3EDxQy", "sipRule": "SDR_NbeMmr9yR8T5", "room": "call+_+13104007909_WQFnLFbGkugV", "participant": "sip_+13104007909", "participantName": "Phone +13104007909", "status": 486, "reason": "participant-failed"} 2025-09-06T134328.039Z INFO sip sip/inbound.go:777 call statistics {"nodeID": "NE_amJpuZhKV8v3", "callID": "SCL_9qLnowY53iB6", "fromIP": "54.172.60.2", "toIP": "livekit.mjreg.site:5060", "fromHost": "pstn.twilio.com", "fromUser": "+13104007909", "toHost": "livekit.mjreg.site", "toUser": "+18568306327", "sipTag": "94102190_c3356d0b_8d93b6ff-69e7-449e-b0d6-ba4acbfb9399", "sipCallID": "df52019a2a498c827e32b8adeda32ca2@0.0.0.0", "twilioAccSID": "AC3c2ec0a3fd5730f5e9757b86e29dd6a7", "twilioCallSID": "CA6fd872a526dd10e4c7a2f731d83338d5", "sipTrunk": "ST_wHMxVZ3EDxQy", "jitterBuf": false, "sipTrunk": "ST_wHMxVZ3EDxQy", "sipRule": "SDR_NbeMmr9yR8T5", "room": "call+_+13104007909_WQFnLFbGkugV", "participant": "sip_+13104007909", "participantName": "Phone +13104007909", "status": 486, "reason": "participant-failed", "stats": {"port":{"streams":0,"packets":0,"packets_ignored":0,"packets_input":0,"mux_packets":0,"mux_bytes":0,"audio_packets":0,"audio_bytes":0,"dtmf_packets":0,"dtmf_bytes":0},"room":{"input_packets":0,"input_bytes":0,"mixer_samples":0,"mixer_frames":0,"output_samples":0,"output_frames":0},"mixer":{"tracks":0,"tracks_total":0,"restarts":0,"mixes":0,"mixes_timed":0,"mixes_jump":0,"mixes_zero":0,"input_samples":0,"input_frames":0,"mixed_samples":0,"mixed_frames":0,"output_samples":0,"output_frames":0}}} Versions / Setup details: LiveKit server: v1.8.0 (Docker) LiveKit SIP server: latest (Docker) Agents repo: cloned from livekit/agents (running locally) Telephony agent: telephony_agent.py from examples VPS: AWS EC2, Ubuntu 22.04, Docker + Docker Compose Twilio SIP trunk: configured with Origination URI pointing to VPS public IP/domain, port 5060 Troubleshooting already done / verified: Inbound SIP sessions appear in LiveKit SIP logs when Twilio calls in. Dispatch rule JSON points incoming calls to a specific LiveKit room and assigns the agent. Agent can successfully join a normal LiveKit room (without SIP involved). SIP trunk credentials and allowed numbers on Twilio are configured (conflict error resolved). Ports 5060 (SIP) and 7880/443 (LiveKit) are open on the VPS. Is there a specific config needed for the agent to auto-join when SIP calls are dispatched? Are there additional logs/flags that help trace why the agent isn’t being pulled into the call? Has anyone successfully tested Twilio β†’ SIP β†’ LiveKit β†’ Agent flow on self-hosted VPS (not LiveKit Cloud) and can share configs?
t
Thanks for reaching out, Pip. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! To help you with the agent not auto-joining the LiveKit room during SIP calls, let’s go through a few things together: 1. First, double-check that the
agentName
in your dispatch rule exactly matches the
agent_name
set in the agent's
WorkerOptions
. Even a small mismatch can stop the agent from joining. 2. Make sure the dispatch rule is set up properly to route calls to the right LiveKit room. The
roomPrefix
and other settings should fit your setup perfectly. 3. Take a peek at the SIP server logs for any errors related to the dispatch rule or agent assignment. Watch out for error codes like 403, 404, or 503β€”they often point to configuration hiccups. 4. Also, confirm that your Twilio SIP trunk is configured correctly with the Origination URI pointing to your LiveKit SIP server's public IP or domain, and that the necessary ports (5060 for SIP, 7880/443 for LiveKit) are open and ready. If you’ve tried all this and things still aren’t working, no worries! We might need some more detailed logs from the LiveKit SIP server and the agent app to dig deeper. Just let me know if you want a hand collecting or going through those logsβ€”I’m here to help! Sources: Inbound calls with Twilio Voice | LiveKit Docs | SIP troubleshooting guide | LiveKit Docs | src/setup-livekit.ts | packages/sip--um-actually/README.md | Getting Help | livekit/livekit_composite | DeepWiki
Hey there! Just to make sure I’m on the same page, when you say "1," are you talking about the first troubleshooting step? Or is there something specific you wanted to ask or share about the issue? I’m here to help!
a
1. "agentName"=telephony_agent , matches 2. { "dispatchRule": { "name": "My Dispatch Rule", "trunkIds": [ "ST_wHMxVZ3EDxQy" ], "rule": { "dispatchRuleIndividual": { "roomPrefix": "call+" } }, "roomConfig": { "agents": [ { "agentName": "telephony_agent" } ] } } } 3. sip server logs show 486 busy and participant failed. 4. Yes ports(5060, 7880 443 are open) , sip trunk is configured correctly.. livekit cloud working fine on the same vps1.
t
Hey there! The 486 Busy Here error means the call was actively rejected by the person or device you’re trying to reach (like the agent or SIP client). Let’s walk through a few things to check that might help fix this: 1. First, make sure the person or device isn’t on "Do Not Disturb," already on another call, or manually declining incoming calls. 2. Take a quick look at your SIP trunk setupβ€”check that the authentication details and allowed numbers line up with what you expect. 3. Double-check the dispatch rule to ensure calls are going to the right agent or room. Also, confirm the
allowed_numbers
in your SIP inbound trunk aren’t accidentally blocking the call. 4. Try turning on detailed logging to catch the
disconnect_reason
for the participant. If you see
USER_REJECTED
, that’s a clear sign of the 486 error. 5. Give it a test run with different numbers or endpoints to see if it’s just one recipient or a wider issue. If none of these tips do the trick, we might need to dig into some extra logs from the LiveKit SIP server and the agent app to get to the bottom of this. Just let me know if you want a hand with gathering or going through those logsβ€”I’m here to help! Sources: livekit-protocol/livekit/protocol/sip.py | SIP troubleshooting guide | LiveKit Docs | Getting Help | livekit/livekit_composite | DeepWiki | SIP Integration | livekit/livekit_composite | DeepWiki | protobufs/livekit_models.proto
a
this is my inbound trunk : Inbound-trunk.json { "trunk": { "name": "My trunk", "numbers": ["+18568306327"] } } will this work ?
t
Hey there! Your inbound trunk configuration looks good for accepting calls to the number +18568306327. Just a couple of friendly tips to make sure everything runs smoothly: 1. If you want to limit calls to certain originating numbers, you can add an
allowed_numbers
field to your setup. 2. If your SIP provider needs authentication, don’t forget to include
auth_username
and
auth_password
. 3. Double-check that the dispatch rule is properly linked to this trunk and routes calls to the right LiveKit room. 4. Give it a quick test by calling the number and see if it connects to the correct room. If anything feels off or you run into trouble, just reach outβ€”I’m here to help! Sources: Accepting inbound calls | LiveKit Docs | SIP inbound trunk | LiveKit Docs | SIP APIs | LiveKit Docs | livekit-protocol/src/livekit.rs | livekit/livekit_sip.pb.go
a
Sharing sip server logs 2025-09-06T134328.039Z INFO sip sip/inbound.go:801 Inbound call closed {"nodeID": "NE_amJpuZhKV8v3", "callID": "SCL_9qLnowY53iB6", "fromIP": "54.172.60.2", "toIP": "livekit.mjreg.site:5060", "fromHost": "pstn.twilio.com", "fromUser": "+13104007909", "toHost": "livekit.mjreg.site", "toUser": "+18568306327", "sipTag": "94102190_c3356d0b_8d93b6ff-69e7-449e-b0d6-ba4acbfb9399", "sipCallID": "df52019a2a498c827e32b8adeda32ca2@0.0.0.0", "twilioAccSID": "AC3c2ec0a3fd5730f5e9757b86e29dd6a7", "twilioCallSID": "CA6fd872a526dd10e4c7a2f731d83338d5", "sipTrunk": "ST_wHMxVZ3EDxQy", "jitterBuf": false, "sipTrunk": "ST_wHMxVZ3EDxQy", "sipRule": "SDR_NbeMmr9yR8T5", "room": "call+_+13104007909_WQFnLFbGkugV", "participant": "sip_+13104007909", "participantName": "Phone +13104007909", "status": 486, "reason": "participant-failed"} 2025-09-06T134328.039Z INFO sip sip/inbound.go:777 call statistics {"nodeID": "NE_amJpuZhKV8v3", "callID": "SCL_9qLnowY53iB6", "fromIP": "54.172.60.2", "toIP": "livekit.mjreg.site:5060", "fromHost": "pstn.twilio.com", "fromUser": "+13104007909", "toHost": "livekit.mjreg.site", "toUser": "+18568306327", "sipTag": "94102190_c3356d0b_8d93b6ff-69e7-449e-b0d6-ba4acbfb9399", "sipCallID": "df52019a2a498c827e32b8adeda32ca2@0.0.0.0", "twilioAccSID": "AC3c2ec0a3fd5730f5e9757b86e29dd6a7", "twilioCallSID": "CA6fd872a526dd10e4c7a2f731d83338d5", "sipTrunk": "ST_wHMxVZ3EDxQy", "jitterBuf": false, "sipTrunk": "ST_wHMxVZ3EDxQy", "sipRule": "SDR_NbeMmr9yR8T5", "room": "call+_+13104007909_WQFnLFbGkugV", "participant": "sip_+13104007909", "participantName": "Phone +13104007909", "status": 486, "reason": "participant-failed", "stats": {"port":{"streams":0,"packets":0,"packets_ignored":0,"packets_input":0,"mux_packets":0,"mux_bytes":0,"audio_packets":0,"audio_bytes":0,"dtmf_packets":0,"dtmf_bytes":0},"room":{"input_packets":0,"input_bytes":0,"mixer_samples":0,"mixer_frames":0,"output_samples":0,"output_frames":0},"mixer":{"tracks":0,"tracks_total":0,"restarts":0,"mixes":0,"mixes_timed":0,"mixes_jump":0,"mixes_zero":0,"input_samples":0,"input_frames":0,"mixed_samples":0,"mixed_frames":0,"output_samples":0,"output_frames":0}}}
t
Hey there! The logs are showing a 486 Busy Here status, which basically means the call got rejected because the person you're trying to reach (like the agent or SIP client) is currently busy. This is a normal SIP response and not something wrong with your LiveKit setup. Here are a few friendly tips to help you out: 1. Double-check that the callee (agent or SIP client) isn’t already on another call or set to "Do Not Disturb." 2. Try adding some retry logic in your app so it can handle busy signals and give the call another shot after a short wait. 3. Look into when the callee is usually free, so you can pick the best times to call if this keeps happening. 4. Let the person who started the call know that the recipient was busy, so they can try again manually or use a different way to reach out. If you keep running into this even when the callee seems free, we might need a bit more info or logs about their status to dig deeper. Just give me a shout if you want help gathering or going through those details! Sources: livekit/livekit_sip.pb.go | livekit-protocol/src/livekit.rs | Runtime/Scripts/Proto/Participant.cs
a
what more info do you need to troubleshoot the issue
t
To help us dig a little deeper into what's going on, it would be great if you could share a bit more info: 1. Logs from the agent application (like telephony_agent.py) so we can see if it's getting the call and why it might be turning it down. 2. What the agent’s state was when the call came in (for example, was it already on another call or just waiting around?). 3. Whether the agent can join a LiveKit room manually without involving a SIP call. 4. Any custom tweaks or changes made to the agent or dispatch rules beyond the usual setup. 5. Network logs or packet captures to check if the SIP signaling is reaching the agent properly and to rule out any network hiccups. With these details, we’ll have a much clearer picture and can get to the bottom of this faster. Just let me know if you’d like a hand with gathering any of this info!
a
{"message": "worker is below capacity, marking as available", "level": "INFO", "name": "livekit.agents", "load": 0.6907999999999997, "threshold": "_WorkerEnvOption(dev_default=inf, prod_default=0.7)", "timestamp": "2025-09-06T153606.222534+00:00"}
t
Hey there! That log message, "worker is below capacity, marking as available," basically means your LiveKit agent worker is running smoothly below its set load limit (which is usually 0.7 by default) and is all set to take on new tasks. This is usually based on how busy the CPU is at the moment. Here are a few friendly tips to help you troubleshoot or fine-tune things: 1. Check if the worker's load threshold fits well with your setup. The default 0.7 means it’ll stop taking jobs once CPU usage hits 70%. 2. Make sure there aren’t any other heavy processes hogging resources on the same machine, as that can mess with load readings. 3. Keep an eye on your logsβ€”if you see the worker flipping between "below capacity" and "at full capacity" a lot, it might be time to tweak the load threshold or think about adding more resources. 4. If you want, you can customize the load function (
load_fnc
) to look at things like memory use or queue length instead of just CPU usage. If you’d like, I’m here to help you adjust these settings or dig deeper into how your worker’s behaving. Just let me know! Sources: Deploying to custom environments | LiveKit Docs | agents/src/worker.ts | Voice Assistants | livekit/livekit_composite | DeepWiki | livekit-agents/livekit/agents/worker.py | Deployment and scaling | LiveKit Docs
a
error 486 busy and on sip server its participant failed . Agent/bot running on local machine is available. help me see where the problem or issue could be because from the sip server logs call was connecting sip server but no livekit room has been created when i did that "lk room list" and no log has been on the livekit server logs . meanwhile "telephony_agent" was running on the local machine.
t
I don't have the answer you're looking for. You could also try asking your question: β€’ in one of the other Slack channels or β€’ to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!