[mod_sofia] Improve outbound REFER result handling (NOTIFY + direct responses) - #3059
Open
mirkobrankovic82 wants to merge 1 commit into
Open
mirkobrankovic82 wants to merge 1 commit into
mirkobrankovic82 wants to merge 1 commit into
Conversation
Author
|
@andywolk @morbit85 could you take a look when you have a moment? This unblocks Happy to adjust anything you want changed. |
mirkobrankovic82
force-pushed
the
fix/refer-notify-terminated-state
branch
from
September 21, 2026 19:40
98dfe29 to
9f96128
Compare
Handle terminated refer NOTIFY without a sipfrag body, surface a direct REFER response in uuid_deflect, make the NOTIFY wait configurable, and keep the original call when a terminated sipfrag is 4xx/5xx. sip_refer_continue_after_reply only skips hangup of the original leg. uuid_deflect still waits for the sipfrag so the API returns the INVITE result.
mirkobrankovic82
force-pushed
the
fix/refer-notify-terminated-state
branch
from
September 29, 2026 11:36
aa21606 to
8d1ee5a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NOTIFYfor thereferevent package whenSubscription-Stateisterminatedbut nomessage/sipfragbody is presentsofia::notify_refercustom events for terminated refer NOTIFYs without payload, including subscription state headers400 Bad Request) by synthesizingsip_refer_replyand unblockingsofia_wait_for_reply()— peers that reject REFER without sending NOTIFY sipfrag no longer cause a timeoutuuid_deflectreturns+OK:SIP/2.0 <status>for final direct REFER responses;202 Acceptedstill waits for NOTIFY per RFC 3515refer-notify-timeout(seconds, default 10) and per-call channel variablesip_refer_notify_timeoutNOTIFYwith4xx/5xxsipfrag (e.g.486) no longer destroys the call nua handle or sendsBYE. Only a200sipfrag hangs up the original dialog (unlesssip_refer_continue_after_replyis set)Problem
After sending a REFER,
mod_sofiawaits for a NOTIFY response viasofia_wait_for_reply(). The wait was previously hardcoded to 10 seconds.Three cases previously left the transfer outcome wrong or tore down the original call:
Terminated NOTIFY without body — some SIP endpoints terminate the refer subscription with
Subscription-State: terminatedand no sipfrag payload. FreeSWITCH ignored these for channel variable purposes and never clearedwant_event.Direct REFER failure — some peers answer REFER with a final SIP status (e.g.
400 Bad Request) instead of202 Accepted+ NOTIFY. FreeSWITCH setsip_refer_status_codebut did not populatesip_refer_replyor unblock the wait.Failed sipfrag + terminated subscription — peers such as Twilio accept REFER with
202, thenNOTIFYsipfrag486(or other>= 300) withSubscription-State: terminated. FreeSWITCH recordedsip_refer_replybut thennua_handle_destroy()sentBYEon the original dialog. The existing channel variablesip_refer_continue_after_replyalready skipped theuuid_deflecthangup and the200sipfrag hangup; it did not skipdestroy_nhon the terminated refer subscription.The 10s wait is also too short for some transfers that still send a final NOTIFY after
202+100 Trying.Config
Sofia profile (default remains 10 seconds):
Per-call override:
Existing channel variable (unchanged meaning):
That variable still skips hangup on a
200sipfrag and skips theuuid_deflectwait/hangup. Keeping the original call after a failed sipfrag (>= 300or terminated with no body) does not require it.