Skip to content

fix(rpc): give a SIP request 3s for a SIP instance to claim it - #1846

Open
cosmin-staicu wants to merge 1 commit into
livekit:mainfrom
UiPath:fix/sip-client-claim-timeout
Open

cosmin-staicu wants to merge 1 commit into
livekit:mainfrom
UiPath:fix/sip-client-claim-timeout

Conversation

@cosmin-staicu

Copy link
Copy Markdown

CreateSIPParticipant and TransferSIPParticipant are queue RPCs that need a claim: a SIP instance takes the queue lock and publishes a claim back before the request is granted. The SIP client sets no selection timeout, so psrpc's 1s default applies, and livekit-server builds this client without retries. A claim that arrives after 1s fails the dial with "no response from servers".

On the Redis bus the claim costs the SIP instance two round trips on pooled connections, the SetNX lock and the claim publish. After an idle stretch longer than the pool's idle limit, both first open fresh TLS connections. That is when we have seen a dial miss the window while the next one, moments later, goes through.

NewSIPClientWithParams now puts a 3s selection timeout ahead of the caller's options, so a caller that sets its own still wins. The timeout only bounds how long an unclaimed request waits. The request is never resent, so a longer window can't place a call twice. A SIP instance that is really gone now fails in 3s instead of 1s.

CreateSIPParticipant and TransferSIPParticipant are queue RPCs that need
a claim: the caller publishes the request, one SIP instance takes the
queue lock and publishes a claim back, and only then is the request
granted. The SIP client never set a selection timeout, so psrpc's 1s
default applied, and livekit-server builds this client without retries
on purpose. A claim that lands after 1s fails the dial outright with
"no response from servers".

On the Redis bus that claim costs the SIP instance two round trips on
pooled connections, the SetNX queue lock and the claim publish. After an
idle stretch longer than the pool's idle limit both open fresh TLS
connections first, which is when a dial has been seen to miss the window
while the next one, moments later, goes through.

NewSIPClientWithParams now puts a 3s selection timeout ahead of the
caller's options, so a caller that sets its own still wins. The window
only bounds how long an unclaimed request waits; the request is never
sent again, so a longer one cannot place a call twice. A SIP instance
that is really gone now fails in 3s instead of 1s.

Signed-off-by: Cosmin Staicu <cosmin.staicu@uipath.com>
@cosmin-staicu
cosmin-staicu force-pushed the fix/sip-client-claim-timeout branch from f7a5043 to 3564cfb Compare October 17, 2026 11:01
@changeset-bot

changeset-bot Bot commented Oct 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3564cfb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
github.com/livekit/protocol Patch
@livekit/protocol Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant