Repository navigation
ReferSubscriber: Fix, build Replaces from the dialog local and remote tags - #992
Open
michele-lunardi-vianova wants to merge 1 commit into
Open
michele-lunardi-vianova wants to merge 1 commit into
michele-lunardi-vianova wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Fixes #817.
Problem
When
RTCSession.refer()is called withoptions.replacesand the session to replace was established by an incoming INVITE, theto-tagandfrom-tagof theReplacesheader in theRefer-ToURI are swapped. A server that follows RFC 3891 then cannot find the dialog: the attended transfer fails and the NOTIFY carriesSIP/2.0 481 Call leg/transaction does not exist.Cause
ReferSubscriber.sendRefer()builds the header from_to_tagand_from_tag, that is the To and From tags of the initial INVITE (code).RFC 3891, section 3:
So, seen from the referrer,
to-tagmust be the remote tag andfrom-tagthe local tag of the dialog to replace. For an outgoing session the From tag is the local one, so the result is right. For an incoming session it is the other way round.This does not show up between two JsSIP endpoints, because
UA._findDialog()accepts both tag orders (code).Fix
Build
Replacesfrom_dialog.id, whichDialogalready fills correctly for both UAC and UAS (code):to-tag=remote_tag,from-tag=local_tag. This is the change proposed by @michelepra in #817.If the session has no confirmed dialog yet, the previous code is kept, so nothing changes there.
Compatibility
Refer-Toheader is identical, byte for byte.Tests
New
src/test/test-ReferSubscriber.tschecks theRefer-Toheader for an outgoing session, an incoming session and a session without a confirmed dialog. The incoming-session test fails without the fix.npm run lintandnpm testpass.I did not touch
CHANGELOG.md; happy to add an entry underNEXTif you want.Manual test
Against an Asterisk-based PBX, with JsSIP 3.13.8 plus this same change (the modified code is the same in 3.13.8 and
master).Bob calls Alice (JsSIP). Alice puts Bob on hold and calls Carol, then sends a REFER on the dialog with Carol, with
Refer-ToBob andReplacesof the dialog with Bob. That dialog was established by an incoming INVITE. The PBX's tags start withas.Before (3.13.8),
to-tagis Alice's tag:After (3.13.8 + this change),
to-tagis the PBX's tag:Bob and Carol end up connected, with two-way audio. A transfer where the replaced dialog was established by Alice still works, with the same
Refer-Toas before.