Skip to content

fix(sip): route in-dialog requests through the proxy's Record-Route path, not back at LiveKit-SIP - #822

Open
rkfshakti wants to merge 4 commits into
livekit:mainfrom
rkfshakti:fix/refer-route-record-route-771
Open

fix(sip): route in-dialog requests through the proxy's Record-Route path, not back at LiveKit-SIP#822
rkfshakti wants to merge 4 commits into
livekit:mainfrom
rkfshakti:fix/refer-route-record-route-771

Conversation

@rkfshakti

Copy link
Copy Markdown

Summary

TransferSipParticipant fails against a multi-hop proxy (Avaya Session Manager): the out-of-dialog REFER gets a Route header pointing at LiveKit-SIP's own address instead of the proxy's Record-Route path. The proxy dutifully forwards to LiveKit-SIP, which doesn't recognize it as a valid inbound request and rejects with 405 — the transfer never completes. Transfers work fine against a direct peer.

Root cause

For an in-dialog UAS request, the dialog's Record-Route set must be applied reversed (RFC 3261 §12.1.1 / §16.12.1.2). NewReferRequest/NewByeRequest already do that reversal when building the request — appending the response's Record-Routes in reverse order as the request's Record-Route set.

swapSrcDst then converts that set to Route headers with PrependHeader per entry — which reverses it a second time, restoring wire order. With a multi-hop proxy, the resulting Route set ends with our own Record-Route as the hop the proxy forwards to: the proxy strips its entry and bounces the REFER back to LiveKit-SIP → 405.

Fix

Append the Route entries in stored order (they are already correctly reversed for the UAS direction). Also fix TestRouteSet's UAS expectation to the RFC-correct reversed order (it was asserting the buggy wire-order).

  • inbound REFER: Route set now [ours, proxy] — we route through the proxy once, it forwards to the peer
  • inbound BYE: same conversion path, fixed together

Fixes #771

…op proxies

swapSrcDst converts the Record-Route set to Route headers with
PrependHeader, which reverses a set that was already reversed for the UAS
direction — restoring wire order. With a multi-hop proxy in the path (e.g.
Avaya Session Manager) that left our own Record-Route as the hop the proxy
forwards to: the proxy stripped its entry and routed the REFER back to
LiveKit-SIP, which rejected it with 405 and the transfer never completed.

Append the Route entries in stored order instead, and update TestRouteSet's
UAS expectation to the RFC-correct reversed order (RFC 3261 §12.1.1, §16.12.1.2).

Fixes livekit#771
@rkfshakti
rkfshakti requested a review from a team as a code owner August 30, 2026 15:18
devin-ai-integration[bot]

This comment was marked as resolved.

@codecov

codecov Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.53%. Comparing base (0460b40) to head (b110feb).
⚠️ Report is 366 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #822      +/-   ##
==========================================
+ Coverage   65.25%   73.53%   +8.28%     
==========================================
  Files          51       43       -8     
  Lines        6588     7498     +910     
==========================================
+ Hits         4299     5514    +1215     
- Misses       1915     1984      +69     
+ Partials      374        0     -374     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rkfshakti

Copy link
Copy Markdown
Author

The multi-proxy review finding is fixed on b110feb: inbound UAS BYE/REFER now builds its Route set from the original INVITE Record-Route headers in wire order, excludes the locally inserted Record-Route, and verifies both header order and transport destination. The focused route test passes repeatedly and all checks are green. A re-review would be appreciated; happy to make any further changes.

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.

SIP transfer fails against a multi-hop proxy (Avaya SM) — REFER's Route header points back at LiveKit-SIP itself

1 participant