Summary:ASTERISK-19355: Call transfer with consultation frequently fails in cross-linked asterisk scenario (directmedia & sendrpid active)
Reporter:Thomas Arimont (tomaso)Labels:
Date Opened:2012-02-14 11:02:35.000-0600Date Closed:2012-03-19 08:58:16
Versions: Frequency of
Environment:i586Attachments:( 0) ASTERISK-19355_synchronized_sip_reinvite_dialogues.patch
( 1) CallTransferWithConsult_Directmedia_NOK.pcap
Description:Actually referring to

A Call transfer with consultation (SIP Refer) fails in a cross-linked asterisk scenario when directmedia and sendrpid is active (two asterisk back to back via SIP trunk/OpenSER).
The reason for that is a faulty interference of SIP (Re-)Invite dialogs. One SIP dialog is already opened although another dialog is still active. The second SIP Re-Invte is therefore rejected by the receiving SIP phone with a SIP 500 Internal Server Error response which finally leads to the release of the resulting transferred call.
Please see the attached wireshark trace for details.

There was already a fix for this in the Asterisk Business Edition C.3 in chan_sip.c but unfortunately this has never made it into the OS Asterisk.

Edit: removed inline patch

When I apply the source code above I cannot reproduce the bug anymore. However it seems reasonable for me to rework the mechanism for avoiding simultaneous Re-Invite dialogs in general considering all implemented independent 'threads' potentially initiating SIP Re-Invites (sendrpid, directmedia, ...) in chan_sip.

With the small patch above there still remains a problem regarding the release of this transferred call. If one side releases the call the call leg on the remote asterisk is frequently not released.
Comments:By: Paul Belanger (pabelanger) 2012-03-02 10:56:58.129-0600

We cannot accept in-line patches, please sign the contributes license agreement and attach your patch to JIRA.  Thanks.

By: Thomas Arimont (tomaso) 2012-03-05 03:22:48.078-0600

please find the inline-patch now as an attached patch file. The patch is made against asterisk-1.8-, but should work with other versions/revisions too.
Please consider my general notice about 'synchronized' sip re-invite dialogues for chan_sip.c in the description.

By: Joshua C. Colp (jcolp) 2012-03-05 10:35:31.264-0600

I have confirmed the patch is the right approach for this and also done a further audit of places where this issue may exist. This will be going into all branches shortly.

As for your comment about hung call legs we will need to see Asterisk console output for the instances involved and SIP traffic. A description of the setup would also be useful for reproducing the issue.

By: Thomas Arimont (tomaso) 2012-03-05 10:46:00.470-0600

good to hear, thanks!
I've already opened a seperate issue ASTERISK-19365 for the 'hung call legs' problem.

By: Jonathan Rose (jrose) 2012-03-19 08:57:36.125-0500

I'm going to go ahead and close this particular issue (and its duplicates) since you mentioned that you have another one for the hung legs problem and this patch is already in 1.8, 10, and trunk.