Skip to content

Answer the final transfer NOTIFY before hanging up the original leg - #25

Merged
calebtt merged 1 commit into
masterfrom
fix/issue-24-transfer-notify
Sep 26, 2026
Merged

calebtt merged 1 commit into
masterfrom
fix/issue-24-transfer-notify

Conversation

@calebtt

@calebtt calebtt commented Sep 26, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #24. This is a follow-up to #18, found while live-testing merged master against the VitalPBX (Asterisk 20.14) lab PBX.

With #18, BlindTransferAsync hung up as soon as the REFER was accepted. Asterisk reports the transfer's progress with in-dialog NOTIFYs (Event: refer, message/sipfrag), sent right after the 202. The last one carries SIP/2.0 200 OK and Subscription-State: terminated. Arriving after the BYE, those NOTIFYs had no dialog to answer them, so the PBX retransmitted each one for ~32 s. The live trace had 3 NOTIFYs and 6 retransmissions.

Change

BlindTransferAsync subscribes to SIPUserAgent.OnTransferNotify before sending the REFER, because the NOTIFYs can arrive right behind the 202. Once the REFER is accepted, it waits up to 5 s (SipClient.TransferNotifyWait) for a sipfrag status of 200 or higher, which SIPUserAgent answers in the dialog. Then it hangs up as before. A transferee that sends no NOTIFY (SIPSorcery's own doesn't) costs the full 5 s before the BYE.

Tests

New Final_progress_NOTIFY_is_answered_before_the_BYE. After accepting the REFER, the transferee sends Asterisk's final NOTIFY. The NOTIFY gets 200 OK, the BYE follows it, and BlindTransferAsync returns in under 3 s. On master the NOTIFY gets no response.

dotnet test: all pass. The transfer tests passed 5 of 5 repeated runs.

Compatibility

BlindTransferAsync now returns after the final progress NOTIFY instead of right after the 202. Against Asterisk that is milliseconds later; against a transferee that sends no NOTIFY it is up to 5 s later. CallEnded and sipbot's ended still follow a successful transfer.

🤖 Generated with Claude Code

With #18, BlindTransferAsync hung up as soon as the REFER was accepted.
Asterisk reports the transfer's progress with in-dialog NOTIFYs (Event:
refer, message/sipfrag) sent right after the 202, the last one with
"SIP/2.0 200 OK" and Subscription-State: terminated. Arriving after the
BYE, they had no dialog to answer them, and the PBX retransmitted each for
~32 s (seen live: 3 NOTIFYs, 6 retransmissions).

BlindTransferAsync now subscribes to OnTransferNotify before sending the
REFER and, once it is accepted, waits for a sipfrag status of 200 or more
(answered in the dialog by SIPUserAgent) for up to 5 s, then hangs up. A
transferee that sends no NOTIFY costs the full 5 s before the BYE.

New test: the transferee sends the final NOTIFY after accepting; it gets
200, the BYE follows it, and BlindTransferAsync returns well within the
cap. On master the NOTIFY gets no response.

Closes #24

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@calebtt
calebtt merged commit 6f74462 into master Sep 26, 2026
2 checks passed
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.

After a blind transfer, the PBX's REFER progress NOTIFYs go unanswered

1 participant