Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #696 +/- ##
==========================================
+ Coverage 65.25% 69.18% +3.93%
==========================================
Files 51 43 -8
Lines 6588 8704 +2116
==========================================
+ Hits 4299 6022 +1723
- Misses 1915 2162 +247
- Partials 374 520 +146 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
db21d39 to
bf6b08f
Compare
|
cleaned up, now only the relevant change |
…ntly dropping
When the dispatch layer returns DispatchNoRuleDrop (e.g. no matching
dispatch rule, or server-side flood decision), the current code calls
cc.Drop() which terminates the SIP transaction without sending any
response. However, by the time the dispatch result is evaluated,
livekit-sip has already sent 100 Trying and 180 Ringing to the carrier,
so the call's existence is already revealed to the caller.
The consequence of the silent drop is that the caller hears indefinite
ringing: the carrier never receives a final response, keeps the INVITE
alive, and only terminates when the caller manually hangs up and a
CANCEL arrives. This wastes carrier resources and delivers a confusing
user experience ("phone rings forever with no answer").
Since the provisional responses already confirm the endpoint to the
caller, sending a 503 Service Unavailable at this point does not leak
any additional information, but it immediately terminates the call on
the carrier side.
Fix: replace cc.Drop() with cc.RespondAndDrop(503) — the same pattern
used by DispatchNoRuleReject and DispatchServiceUnavailable.
Observed via SIP trace (Homer/HEP): INVITE → 100 → 180 → [13 second
gap, no final response] → CANCEL from carrier. livekit-sip logs showed
"Closing inbound call / status=486 / reason=flood" with no corresponding
"Inbound call closed" entry, confirming the SIP response was never sent.
bf6b08f to
6bbc00b
Compare
|
Rebased onto current Test update. #853 (TELCU-30) added On the port-scan rationale. The silent drop came in with #60 ("Support dropping connections to prevent port scans"). That makes sense when nothing has been sent yet. Since the call-flow rework in #165, however,
We've been running this in production since May (on v1.3.0; the rebased version on v1.17.0 is rolling out now) and would be glad to drop our fork. |
There was a problem hiding this comment.
🔍 Devin Review: 2 flags
Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
|
@simllll thanks for submitting the PR. I am not able to reproduce the issue though.
Are you using livekit cloud? The Let me know if you still see the problem. |
|
Hi, thanks for looking into it! We are self hosting (OSS livekit-server, currently 1.13.7), not cloud - I guess that's the difference. On OSS it's still a drop in both cases as far as I can see:
So the carrier keeps ringing until the caller hangs up. Maybe the drop -> reject change is only in the cloud dispatch service? If it's in OSS somewhere I'd be happy if you could point me to it ;-) My repro steps in the description were a bit misleading, sorry - updated them. Easiest way on OSS: inbound trunk for the number, but no dispatch rule that matches it. You get 100, 180 and then silence until CANCEL. With this PR you get a 503 right after the 180. |
|
I'd prefer the change in livekit/livekit#4927 so that we can preserve the contract that "drop" means drop silently. cc @dennwc |
|
Closing as we took care of it here -> livekit/livekit@edb19c9 |
Problem
When the dispatch layer returns
DispatchNoRuleDrop(no matching dispatch rule, or a server-side DROP decision),handleInvitecallscc.Drop()which terminates the SIP transaction without sending any SIP response. However, by the time the dispatch result is evaluated, livekit-sip has already sent100 Tryingand180 Ringingto the carrier, so the call's existence is already revealed.The result: the caller hears indefinite ringing. The carrier never receives a final response, keeps the INVITE transaction alive, and only terminates when the caller manually hangs up and a CANCEL arrives. This wastes carrier resources and produces confusing UX.
Observed via SIP trace (Homer/HEP):
livekit-sip logs showed
Closing inbound call / status=486 / reason=floodwith no subsequentInbound call closedentry, confirming the SIP response was never transmitted. Theclose()call afterDrop()callsCloseWithStatus(), which checksinviteTx != nilto send the response — butDrop()already setinviteTx = nil, so no response is sent.Fix
Replace
cc.Drop()withcc.RespondAndDrop(sip.StatusServiceUnavailable, "Service Unavailable")— the same pattern used byDispatchNoRuleRejectandDispatchServiceUnavailable.RespondAndDropsends the final response first, then terminates the transaction, soclose()/CloseWithStatus()correctly becomes a no-op.Why 503 and not silent drop?
The intent of
DispatchNoRuleDropappears to be "don't reveal endpoint information." However, since100 Tryingand180 Ringingare already sent before dispatch runs, the endpoint's existence is already revealed by the timeDrop()is called. Sending a503at this point leaks no additional information, but it immediately terminates the call at the carrier side instead of leaving it hanging.The auth-level
AuthDrop(which fires before any provisional response is sent) is a different case and correctly remains a silent drop.Testing
Self-hosted (OSS livekit-server), easiest repro: create an inbound trunk for a number, but no dispatch rule that matches it, then call the number.
Same thing happens for an INVITE that matches no trunk at all (auth returns empty -> accept, then dispatch returns DROP).
TestInboundCallStatusCode/DispatchDropis updated to expect the 503 and the recordedCallStatusCode, same asDispatchReject.