important-judge-78504
10/01/2025, 9:38 PMtall-airline-16756
10/01/2025, 9:38 PMtall-airline-16756
10/01/2025, 9:39 PMcreate_sip_participant for you:
• ringingTimeout: This sets the maximum time the callee has to answer the call before it ends. Think of it as a SIP-level timeout, with a maximum limit of 80 seconds.
• timeout: This controls how long your client waits for a response from the LiveKit server when creating the SIP participant. It’s an RPC-level timeout.
How these two work together depends on the waitUntilAnswered flag:
• When waitUntilAnswered = true: The API call will wait (or block) until the callee either answers or the call fails. To avoid the call being cancelled too soon, make sure your timeout is set higher than ringingTimeout.
• When waitUntilAnswered = false: The API call returns right after starting the call. Here, timeout only needs to cover the call initiation, while ringingTimeout independently manages how long the phone rings.
Feel free to adjust these values based on what fits your situation best, so you get the right balance between call behavior and API response timing. If you have any questions or need further guidance, I’m here to help!
Sources: packages/livekit-server-sdk/src/SipClient.ts | pkg/service/sip.go | cmd/lk/sip.go | protobufs/livekit_sip.proto | Docs::Telephonyimportant-judge-78504
10/01/2025, 9:41 PMtall-airline-16756
10/01/2025, 9:42 PMasyncio.TimeoutError and TwirpError. Let’s walk through this together:
• asyncio.TimeoutError: This happens when the client doesn’t get a response from the LiveKit server within the set timeout. It’s a client-side issue and usually points to a network or server delay. You can handle this in your code to manage such delays gracefully.
• TwirpError: This is a server-side error that carries SIP-specific details like sip_status_code and sip_status. For instance, a SIP 408 error means the callee didn’t answer within the ringingTimeout.
Here are a couple of tips to help you improve your error handling:
• Make sure your timeout is set longer than ringingTimeout so your client waits sufficiently for the SIP process to finish.
• Take a close look at the TwirpError metadata to tell apart a timeout (like SIP 408) from other issues. For example:
except api.TwirpError as e:
sip_code = e.metadata.get('sip_status_code')
if sip_code == '408':
print("Call failed: Remote party did not answer within ringingTimeout.")
else:
print(f"SIP error: {sip_code} {e.metadata.get('sip_status')}")
By syncing your timeout and ringingTimeout settings and using the error metadata, you’ll be able to clearly distinguish between these cases and handle them smoothly in your application. If you have any more questions or need further help, I’m here for you!
Sources: cmd/lk/sip.go | packages/livekit-server-sdk/src/SipClient.ts | agent.py | Agents telephony integration | LiveKit Docs | livekit-rtc/livekit/rtc/participant.pyimportant-judge-78504
10/02/2025, 1:34 PMtall-airline-16756
10/02/2025, 1:35 PMringingTimeout runs out, the Go context for the SIP call gets canceled, and this cancellation shows up as a Twirp "Canceled" error. It’s important to know that this process skips the usual SIP-level status code mapping (like SIP 408) which is used internally but doesn’t appear in the final API response.
To help you manage this smoothly, here are some friendly tips:
• Make sure to explicitly catch and handle the Twirp "Canceled" error in your client code.
• Use lksdk.SIPStatusFrom(err) to pull out SIP-specific details (such as SIPStatusCode and SIPStatus) from the error object—this can give you clearer insights when diagnosing issues.
• Check that your ringingTimeout is set to a sensible value that fits typical call setup times (the default is 3 minutes).
• If you want to avoid long waits on the client side, consider setting WaitUntilAnswered=false for asynchronous behavior.
Following these steps should make it easier to tell the difference between a timeout and other interruptions, helping you keep your error handling clear and effective. If you have any more questions or need further assistance, I’m here to help!
Sources: pkg/sip/protocol.go | livekit/livekit_sip.twirp.go | cmd/lk/sip.goimportant-judge-78504
10/02/2025, 1:38 PMtall-airline-16756
10/02/2025, 1:39 PMcreate_sip_participant actually depends on the SDK you're using and the wait_until_answered flag:
• For the Go server, the default timeout is 30 seconds if WaitUntilAnswered is false, and it extends to 80 seconds when WaitUntilAnswered is true.
• In the Node.js SDK, you'll find the default is 60 seconds when waitUntilAnswered is true, and a shorter 10 seconds otherwise.
• With the Python SDK, the timeout defaults to 20 seconds if wait_until_answered is true, but this applies only if your client’s configured timeout is less than 20 seconds.
These timeouts vary across SDKs and tend to be longer when waiting for the call to be answered. If you'd like, I’m here to help you adjust these settings to perfectly fit your needs—just let me know!
Sources: packages/livekit-server-sdk/src/SipClient.ts | cmd/lk/sip.go | pkg/service/sip.go | livekit-protocol/livekit/protocol/sip.pyiimportant-judge-78504
10/02/2025, 1:40 PMwait_until_answered = True. so the ringingTimeout needs to be shorter than the client timeout?tall-airline-16756
10/02/2025, 1:40 PMwait_until_answered=True, it's important that the ringingTimeout is set to a value shorter than the client timeout. This helps make sure your SIP call has enough time to connect within the client’s waiting period.
For instance, if your ringingTimeout is 30 seconds, I’d recommend setting the client timeout to around 35–40 seconds. This little buffer allows for any extra processing time and helps avoid the client timing out too soon while the call is still ringing.
If you’d like, I’m here to help you fine-tune these settings or answer any other questions you might have!important-judge-78504
10/02/2025, 1:41 PMtall-airline-16756
10/02/2025, 1:42 PMringingTimeout is set shorter than the client timeout, you typically won't see an asyncio.TimeoutError unless there's a network hiccup or the server stops responding. Instead, when the ringingTimeout runs out, the server will cancel the SIP call and return a Twirp "Canceled" error, just like we talked about earlier.
This setup helps keep things clear: the client timeout covers the whole API call duration, while the ringingTimeout specifically manages the SIP call timing.
If you'd like, I'm here to help with any more questions or to walk you through error handling strategies. Just let me know!important-judge-78504
10/02/2025, 1:43 PMtall-airline-16756
10/02/2025, 1:43 PMlksdk.SIPStatusFrom(err), which lets you pull out SIP-specific details like SIPStatusCode and SIPStatus.
Here’s a simple example to guide you:
try:
participant = await livekit_api.sip.create_sip_participant(request, timeout=45)
except api.TwirpError as e:
sip_code = e.metadata.get('sip_status_code')
sip_message = e.metadata.get('sip_status')
if sip_code == '408':
print("Request timeout: The callee did not answer within the ringingTimeout.")
elif sip_code:
print(f"Request interruption: SIP error {sip_code} - {sip_message}")
else:
print(f"Unknown error: {e.message}")
By checking the SIPStatusCode, you’ll be able to tell if the issue was a timeout (like SIP 408) or some other kind of interruption, such as network troubles or call rejection. If you have any questions or want to explore this further, feel free to ask—I’m here to help!important-judge-78504
10/02/2025, 1:44 PMtall-airline-16756
10/02/2025, 1:44 PMSIPStatusCode or SIPStatus), that usually means it's a SIP-level issue. For instance, a SIP 403 or 404 would suggest the call was rejected or the number was invalid.
• If there’s no SIP metadata and the error relates to the RPC or HTTP layer (such as "deadline exceeded" or "context canceled"), it’s probably a transport-level timeout or interruption.
To dig a bit deeper, you might want to:
• Look at the error response for SIP-specific details using lksdk.SIPStatusFrom(err).
• Double-check your timeout settings for wait_until_answered and the client-side timeout to make sure they’re in sync.
• Keep an eye on participant events (like sip.callStatus) to see how the call is progressing after it starts.
Please feel free to reach out if you'd like a hand with these checks or need help tweaking your setup—I’m here to support you!
Sources: livekit-api/livekit/api/sip_service.py | packages/livekit-server-sdk/src/SipClient.ts | Docs::Agents | livekit/livekit_sip.pb.go | cmd/lk/sip.goimportant-judge-78504
10/02/2025, 1:46 PMtall-airline-16756
10/02/2025, 1:46 PMSIPStatusCode or SIPStatus, if they’re available.
• Review the error context in your logs to see if it was triggered by a timeout or an explicit cancellation.
• Double-check that your timeout and ringingTimeout settings are properly configured to prevent any premature cancellations.
If you'd like, I’m here to help you walk through these steps or troubleshoot any specific situations you’re facing. Just let me know!