Is the ring time different from carriers to carrie...
# ask-ai
h
Is the ring time different from carriers to carriers and from phones to phones so they can't be reliably controlled by the
ringingTimeout
field in
sipClient.createSipParticipant
?
t
Thanks for reaching out, tri.nguyen. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking whether ring duration varies by carrier and phone, and if that makes
ringingTimeout
unreliable. Short answer: yes — ring time can vary, so
ringingTimeout
cannot guarantee the exact on-device ring duration. Explanation and practical guidance: •
ringingTimeout
sets how long LiveKit will wait for a final response (answer/reject) after sending the INVITE. It prevents indefinite waiting. • Carriers and endpoint devices control actual on-network/onscreen ringing behavior (some carriers cut off ringing at ~30s, others at ~60s or more; device/voicemail settings can also affect this). • The effective ring period is the shorter of the carrier/device behavior and your configured
ringingTimeout
. You cannot force carriers/devices to respect a longer ring via this field. • For predictable behavior, set
ringingTimeout
to a value within common carrier limits (commonly 30–60s). LiveKit enforces an upper limit of 80s. If you want, tell me the timeout you’re considering and the typical regions/carriers you call so I can recommend a practical
ringingTimeout
value. Sources: SIP APIs | LiveKit docs | Make outbound calls | LiveKit docs
h
export function determineTerminationReasonFromCallStatus( callStatus: string | undefined, callStartTime: Date, ): CallTerminationReason { const callDuration = Date.now() - callStartTime.getTime(); const RINGING_TIMEOUT_MS = 30 * 1000; // 30 seconds switch (callStatus) { case 'ringing': return callDuration >= RINGING_TIMEOUT_MS ? CallTerminationReason.TIMEOUT : CallTerminationReason.NO_ANSWER; case 'dialing': return CallTerminationReason.SIP_ERROR; case 'hangup': return CallTerminationReason.COMPLETED; default: return CallTerminationReason.SIP_ERROR; } } Where callStatus is disconnectedParticipant.attributes['sip.callStatus'] Using this method, it's not always reliable to detect when TIMEOUT occurs Any suggestion?
t
Thanks — you’re right that using only
sip.callStatus
+ a fixed duration can be unreliable. A few focused suggestions to improve accuracy: 1. Prefer explicit SIP final responses when available • If you can access SIP response codes or final event types (e.g.,
487 Request Terminated
,
486 Busy Here
,
480 Temporarily Unavailable
, 200 OK), map those to termination reasons instead of inferring from time. Final SIP responses are definitive. 1. Use server-side call lifecycle events (if available) • Check any LiveKit or SIP gateway events/attributes that indicate call termination reason (e.g.,
sip.responseCode
,
sip.terminationReason
, or disconnect event metadata). These are more reliable than elapsed time. 1. Combine status + timing as a heuristic (improved): • Keep your
ringingTimeout
heuristic, but widen detection and add states: ◦ If
callStatus === 'ringing'
and
callDuration >= RINGING_TIMEOUT_MS
→ likely TIMEOUT (as you have). ◦ If
callStatus === 'ringing'
and you later receive a SIP final response (even after timeout), update the reason based on that response. ◦ If
callStatus === 'dialing'
and no SIP responses arrive within a short network timeout → treat as SIP_ERROR/NO_ROUTE. 1. Track intermediate events and timestamps • Persist timestamps for when you sent INVITE, first 180/183 provisional response (if seen), and final response. Use those to distinguish slow network vs. carrier-side cutoffs. 1. Add short grace period and re-check on async updates • Carriers/devices sometimes respond late. After your timeout, mark TIMEOUT but keep listening for a short grace window (e.g., 5–10s). If a final SIP code arrives, override the termination reason. 1. Log and surface SIP codes for edge cases • When you can’t map a reason, log the SIP response code,
sip.callStatus
, and timestamps. This helps tune
RINGING_TIMEOUT_MS
per carrier/region. 1. If you only have
sip.callStatus
(no SIP codes): • Use a slightly longer
RINGING_TIMEOUT_MS
(30–60s depending on region). • Combine with the grace-window override approach and logging to catch late final responses. If you’d like, share: • which attributes/events you do get on disconnect (full
disconnectedParticipant.attributes
), and • the regions/carriers where you see incorrect detection. I can then suggest a concrete mapping or a revised function that merges status, timestamps, and any available SIP codes.