im having an issue where when using sip trunk with...
# ask-ai
r
im having an issue where when using sip trunk with vonage the bye message is being sent 30 seconds late so the room is always closed too late.
t
Thanks for reaching out, Hamza. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I hear you: the BYE from Vonage is arriving ~30s late and that keeps the LiveKit room open longer than expected. I can help troubleshoot — a few focused questions and one quick test will narrow this down. 1) Environment details • Which LiveKit server version are you running? • Are you using LiveKit’s SIP gateway (built-in) or a custom SIP proxy? • Is this happening for all calls or only specific numbers/regions? 2) Logs & timing • Can you share call flow timestamps or SIP logs showing the INVITE, SDP/ACK, and the delayed BYE? Specifically the SIP message timestamps around call teardown. • From LiveKit logs, what timestamp does the room-closure event show relative to the BYE? 3) SIP settings to check • Do you have any timers or retransmission settings configured in your SIP gateway/proxy (e.g., session timers like
Session-Expires
,
Timer
, or custom media timeouts)? • Does Vonage send a 200 OK to BYE immediately and only send BYE late, or is BYE itself delayed from their side? 4) Quick test to isolate source • If possible, place a call through the same LiveKit SIP gateway but using a different SIP provider or a direct SIP UA (softphone). Does BYE timing match Vonage or close instantly? This shows whether the delay is on Vonage’s side or in the LiveKit/SIP gateway. What I can do next • If you share the SIP call timestamps or logs, I’ll look for where the 30s delay originates (Vonage->gateway or gateway->LiveKit) and recommend specific setting changes (e.g., session timer adjustments, retransmit timers, or explicit media timeout handling). Which logs can you provide first: Vonage SIP trace around teardown, or LiveKit SIP/gateway logs with timestamps?
r
Here’s what I can confirm from the current setup: 1) Environment details • LiveKit version: The worker startup log shows livekit.agents v1.3.5 with RTC 1.0.19 (the server side is LiveKit Cloud, so that’s the version we interact with). • SIP setup: We’re using LiveKit Cloud’s built-in SIP service—no custom SIP proxy. Outbound calls go through the LiveKit SIP trunk we configured in the dashboard/API; Vonage is the upstream carrier. • Scope: The 25–30 s tail happens on every Vonage call we’ve tested (same number/region). Calls never close immediately, so it’s consistent, not sporadic. 2) Logs & timing • LiveKit agent logs show the participant disconnect event at 144638 even though the user hung up around 144606. That’s a ~32 s gap. The room closes right after LiveKit receives the disconnect (no extra delay inside our code). • We don’t currently have Vonage SIP traces in the repo, but the LiveKit log timing aligns with “Vonage doesn’t send BYE until ~30 s later.” 3) SIP settings • We haven’t configured any SIP timers or retransmission overrides in LiveKit; it’s the default Cloud SIP behavior. • Because LiveKit only shuts down once it receives the BYE from Vonage, and we see participant disconnect precisely when Vonage finally signals hangup, the BYE itself is delayed on their side—not a missing 200 OK. 4) Quick test • We haven’t yet run the “call through a different SIP provider/softphone” test. That would be a good next step to prove the delay is specific to Vonage. With the current evidence (constant 30 s tail, immediate shutdown after BYE), the bottleneck is Vonage’s hangup timing. What you can share • If you can pull Vonage SIP traces (INVITE → call → BYE) or LiveKit’s SIP gateway logs showing when BYE arrives, I can point at the exact timestamp. But given everything we’ve seen, the fix is to adjust Vonage’s session timers/post-call delay so BYE is emitted immediately.
t
Thanks — this matches what you described. The 30s tail is caused by Vonage delaying the BYE; LiveKit closes the room immediately when it receives BYE, so the carrier-side timing is the source. Recommended next steps: • Get Vonage SIP traces (INVITE → media → hangup → BYE) showing timestamps to confirm Vonage is sending BYE ~30s after the user disconnects. • Ask Vonage to check/adjust: ◦ Session timer / Session-Expires and refresher settings. ◦ Any "immediate BYE" / post-teardown delay behavior. ◦ Re-INVITE/hold/hangup handling that might postpone BYE. • Run a control test: place the same call through a different SIP provider or a softphone to prove the delay is specific to Vonage. If you need a temporary workaround in LiveKit Cloud (if changing Vonage settings isn’t possible), you can implement a short agent-side grace timeout to force-close the room after detecting local hangup — only if that aligns with your business rules. Tell me which logs you can share first: Vonage SIP trace or LiveKit SIP gateway logs with timestamps, and I’ll analyze timestamps and suggest the exact config change to request from Vonage. Sources: Accepting inbound calls | LiveKit docs | Make outbound calls | LiveKit docs | SIP troubleshooting guide | LiveKit docs | SIP overview | LiveKit docs
r
if i do this temporary fix on my provider side then any client who also uses sip trunking using our application will have to apply this setting. platforms like vapi dont need this they already work with accurate timings
t
You're right to be concerned — applying an agent-side workaround on each client integration is not ideal. Short answer • Yes: a temporary client-side forced-close (grace timeout) must be implemented by each integration that wants to avoid the 30s tail. That means every customer using your app’s SIP trunking would need that change if Vonage’s behavior stays as-is. • Better: fixing the root cause at Vonage (carrier-side session timers / immediate BYE behavior) removes the need for per-client changes. Why other platforms (like VAPI) don't need it • Platforms that don't show the tail typically have carrier/trunk settings already configured to emit BYE immediately (session timers, teardown behavior, or specific Vonage account options). LiveKit reacts as soon as it receives BYE, so carrier configuration is the differentiator. Recommended next steps 1. Collect a Vonage SIP trace showing the delayed BYE (timestamps). 2. Ask Vonage to adjust session timers or enable immediate BYE/post-teardown behavior for your trunk — I can help draft the exact request. 3. Meanwhile, if you must avoid any user-visible tail for some clients, deploy the short grace-period workaround only for those clients (document it as temporary). If you want, tell me which option you prefer and I’ll draft a concise support request to Vonage with the exact timestamps and settings to ask them to change.
r
so how can i address the root cause and make sure all my clients have the same fix
t
Good—you want a carrier-side fix so all clients get the same behavior. Here’s a concise, actionable plan you can execute and share with Vonage. 1) Gather logs to prove the problem • Collect a representative SIP trace for a call: INVITE → 200 OK → ACK → (hangup) → BYE with exact timestamps. • Include LiveKit SIP gateway logs showing when LiveKit received the BYE and the participant disconnect time. 2) Ask Vonage to change these trunk/session settings • Reduce Session-Timers: set
Session-Expires
to 90–300s (recommend 180s) and
Min-SE
to 90s. • Ensure Vonage sends BYE immediately on hangup (disable any “post-teardown hold” or delayed teardown behavior). • Confirm re-INVITE/refresh handling won’t delay BYE (no waiting for other events before teardown). • Ask Vonage to confirm their SIP timer values (T1/T2) and any carrier-side grace periods on call end. 3) Example text you can send to Vonage "We’re seeing a consistent ~30s delay between user hangup and the BYE sent toward our LiveKit SIP trunk, causing rooms to stay open. Attached are SIP traces and LiveKit timestamps. Please reduce Session-Expires to 180s (Min-SE 90s) and enable immediate BYE on hangup or otherwise remove any post-disconnect hold/grace period so BYE is forwarded promptly." 4) Verify after Vonage changes • Re-run the same call and confirm BYE arrives within seconds of hangup. • Check LiveKit logs for participant disconnect time matching the hangup timestamp. • If still delayed, provide Vonage the SIP traces for further carrier debugging. 5) If you want, I can: • Draft the exact support message with your timestamps and sample SIP trace snippets formatted for Vonage. • Review Vonage’s response or the post-change logs and recommend next steps. Which would you like me to do next: draft the support message with timestamps you give me, or wait for Vonage’s reply and then analyze their logs? Sources: SIP APIs | LiveKit docs | sip | livekit/livekit_composite | DeepWiki | Still Have Questions | SIP troubleshooting guide | LiveKit docs | Agents telephony integration | LiveKit Docs
r
but this would require vonage to only apply the fix on our account. if customers byo their own sip trunk through vonage it wont fix the issue for them.
t
You're right — a fix applied only to your Vonage account won't affect customers who BYO their own Vonage trunks. Here are concise, practical options to get a consistent experience for all clients. 1) Preventative: make BYO trunks behave correctly • Provide customers a short config checklist to apply to their Vonage trunks: ◦ Set Session-Expires to 90–300s (recommend 180s) and Min-SE to 90s. ◦ Enable immediate BYE on hangup (or disable any post-teardown grace period). ◦ Prefer TCP/TLS transport to reduce UDP retransmission delay. • Offer that checklist as part of your onboarding docs or a one-click config guide. 2) Application-level, single-source controls (your app applies to all clients) • Implement server-side cleanup that runs centrally for all calls routed through your service: ◦ Monitor SIP and participant events; when your side detects a local hangup, start a short grace timer (e.g., 2–5s) then call the LiveKit DeleteRoom / hangup API to force closure if BYE hasn’t arrived. ◦ Use
ringing_timeout
and
max_call_duration
where appropriate to prevent long-lived sessions. • Deploy this as part of your backend so customers don’t need per-client changes. 3) Carrier advocacy for a universal fix • Ask Vonage to: ◦ Apply session-timer and immediate-BYE defaults across trunks (or offer a vendor-level setting you can buy/enable). ◦ Provide a documented setting for customers to enable on their own accounts. • Provide Vonage traces and reproducible cases to accelerate their changes. 4) Recommended rollout strategy (minimal client impact) • Immediately publish the Vonage config checklist and request customers apply it. • Simultaneously roll out the centralized server-side cleanup in your backend for any trunks that still show the issue (short grace timer + forced hangup). • Follow up with Vonage to get defaults improved so you can remove forced cleanup later. I can draft: • The exact Vonage configuration checklist text for your docs. • A short server-side pseudocode snippet or API call sequence to force-close rooms after a small grace period. Which do you want first — the customer-facing checklist or the backend pseudocode? Sources: Still Have Questions | Secure trunking | LiveKit docs | SIP outbound trunk | LiveKit docs | Create and configure a Plivo SIP trunk | LiveKit docs | SIP inbound trunk | LiveKit docs
a
Hey Hamza, we are experiencing same issue with Twilio. And have asked same question. The reason is Vapi uses direct web socket not sip. To apply this you will need to modify how livekit works and that isn’t ideal. Livekit sip comms is more efficient but requires the user to build an elastic sip trunk / connection on their provider side
t
Thanks — you’re right: the same carrier-side behaviour (Vonage, Twilio) causes the delayed BYE, not LiveKit. I’ll keep this short and actionable. Why this happens • Carriers can delay BYE due to session-timers, teardown/grace-period logic, or signaling transport/retransmit behavior. LiveKit closes the room as soon as it receives BYE, so late BYE = late room close. Options to fix at scale 1) Carrier-level (best, uniform) • Have each carrier (Vonage, Twilio) apply shorter session timers and immediate-BYE behavior for your trunks or offer a vendor-level default. • Required settings to request: Session-Expires ~90–300s (recommend 180s), Min-SE 90s, immediate BYE on hangup, confirm transport (TCP/TLS) and any post-teardown grace periods are disabled. 2) Customer BYO guidance (necessary for third-party trunks) • Publish a short checklist customers can apply to their own trunks (session timers, immediate BYE, transport). • Provide a one-page onboarding/config snippet for Vonage/Twilio to reduce friction. 3) Centralized application-side fallback (what you can deploy once) • Implement backend logic that applies to all calls routed through your service (no per-client code change): ◦ Detect local hangup or signaling indicating call end. ◦ Start a small grace timer (2–5s). ◦ If BYE hasn’t arrived, call LiveKit’s hangup/DeleteRoom to force closure. • This avoids modifying LiveKit core and gives an immediate, centralized mitigation for all customers (including BYO trunks). 4) Long-term options • Push carriers to change defaults for all trunks, or • Offer a non-SIP path (WebSocket-based) as a premium option for customers who need exact timing like VAPI. Which help do you want next? • I can draft the exact support request text for Vonage/Twilio with your timestamps and SIP trace template, or • I can draft the customer-facing configuration checklist and a short backend pseudocode snippet for the centralized fallback. Which one should I prepare first?