# Asterisk 13 don't send INVITE with Replaces after accepted REFER

**URL:** <https://community.asterisk.org/t/asterisk-13-dont-send-invite-with-replaces-after-accepted-refer/66801>\
**Category:** Asterisk Support\
**Created:** [May 25, 2016, 9:37am UTC](https://community.asterisk.org/t/asterisk-13-dont-send-invite-with-replaces-after-accepted-refer/66801 "2016-05-25T09:37:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jose.molina](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jose.molina](https://community.asterisk.org/u/jose.molina)\
**Post date:** [May 25, 2016, 9:37am UTC](https://community.asterisk.org/t/asterisk-13-dont-send-invite-with-replaces-after-accepted-refer/66801/1 "2016-05-25T09:37:58Z")

</div>

Hi;

We use Asterisk as a gateway to connect PSTN with our SIP platform with a SIP trunk. We upgraded our Asterisk gateway from version 11 to 13. After the migration, we have an issue with attended transfer. This is the scenario:

1- PSTN number (user A) calls any extension of our SIP platform (user B). B answer the call  
2- user B holds the incoming call and makes a second call to other SIP extension (user C) to initiate an attended transfer.  
3- user B transfers the call for try to join A and C users but this transfer fails.

Analyzing the signalling traffic, we can see that the REFER message arrives from B to the gateway Asterisk with the Replaces header. Asterisk accepts the REFER message with a 202 Accepted response but doesn’t send the INVITE with the replaces message to do the transfer.

The TRANSFER\_CONTEXT variable is defined but the call no execute any line of code defined in the dialplan from this context.

These are the sip.conf and dialplan configuration:

**sip.conf**

[general]  
[domain=mydomain.com](http://domain=mydomain.com)  
autodomain=no  
[fromdomain=mydomain.com](http://fromdomain=mydomain.com)  
context=default  
udpbindaddr=0.0.0.0:5100  
tcpenable=no  
transport=udp  
preferred\_codec\_only=yes  
disallow=all  
allow=alaw,g729  
nat=force\_rport,comedia  
canreinvite=no  
directmedia=no  
allowtransfer=no  
pedantic=no  
dtmfmode=rfc2833  
trustrpid=yes  
srvlookup=no  
rtptimeout=60  
cos\_audio=5  
cos\_sip=3  
tos\_sip=cs3  
tos\_audio=ef

[ISP\_SIPtrunk]  
type=peer  
[domain=mydomain.com](http://domain=mydomain.com)  
autodomain=no  
context=incoming  
host=1.1.1.1  
[fromdomain=mydomain.com](http://fromdomain=mydomain.com)  
insecure=port,invite  
trustrpid=yes  
nat=force\_rport,comedia  
directmedia=no  
pedantic=no  
allowtransfer=no  
canreinvite=no  
dtmfmode=rfc2833  
preferred\_codec\_only=yes  
disallow=all  
allow=alaw,g729  
srvlookup=no  
rtptimeout=60  
qualify=yes ; SIP OPTIONS (check Agent OK)  
qualifyfreq=60 ; 60 seconds

[PROXY-out]  
type=peer  
[domain=mydomain.com](http://domain=mydomain.com)  
autodomain=no  
host=2.2.2.2  
port=5070  
[fromdomain=mydomain.com](http://fromdomain=mydomain.com)  
context=outgoing  
preferred\_codec\_only=yes  
disallow=all  
;allow=alaw  
allow=alaw,g729  
allowtransfer=yes  
canreinvite=no  
nat=force\_rport,comedia  
;nat=yes  
pedantic=no  
directmedia=no  
dtmfmode=rfc2833  
defaultexpiry=300  
trustrpid=yes  
srvlookup=no  
rtptimeout=60

**extensions.conf**

[general]  
static=yes  
writeprotect=yes  
language=es

[globals]

TRANSFER\_CONTEXT=station\_transferUC  
\_TRANSFER\_CONTEXT=station\_transferUC  
\_\_TRANSFER\_CONTEXT=station\_transferUC

…

[station\_transferUC]

; – Masquerade NAT users  
exten =\> \_uX-X.,1,Macro(transferUCAAi,${EXTEN},${CALLERID(num)},${UCLID})

; — URIs  
exten =\> \_[a-zA-Z.-@].,1,Macro(transferUCAAi,${EXTEN},${CALLERID(num)},${UCLID})

; INTERNS  
exten =\> \_X.,1,Macro(transferUCAAi,${EXTEN},${CALLERID(num)},${UCLID},${IPGW2})

…

[macro-transferUCAA]  
; Transfer Active-Active with failover Gateway. Variable ${UCUSER} ve del INVITE original  
exten =\> s,1,NoOp(Transfer call ${ARG2} to ${ARG1}. Prefix ${ARG3}. GWFailover ${ARG4}. --UCUser: ${UCUSER}–)  
exten =\> s,n,Set(NUMDESTI=${ARG1})  
exten =\> s,n,Set(NUMORIGEN=${ARG2})  
exten =\> s,n,Set(CALLEDPREFIX=${ARG3})  
exten =\> s,n,Set(GWFAILOVER=${ARG4})

…

In the Asterisk CLI we can see:

== Using SIP RTP TOS bits 184  
== Using SIP RTP CoS mark 5  
– Executing [25988@incoming:1] Macro(“SIP/ISP\_SIPtrunk-00000000”, “llamadaEntranteUC,25988,37233”) in new stack  
– Executing [s@macro-llamadaEntranteUC:1] NoOp(“SIP/ISP\_SIPtrunk-00000000”, “CallingPress --1-- caller id --“37233” \<37233\>–”) in new stack  
– Executing [s@macro-llamadaEntranteUC:2] Set(“SIP/ISP\_SIPtrunk-00000000”, “TRANSFER\_CONTEXT=station\_transferUC”) in new stack  
– Executing [s@macro-llamadaEntranteUC:3] Set(“SIP/ISP\_SIPtrunk-00000000”, “\_TRANSFER\_CONTEXT=station\_transferUC”) in new stack  
– Executing [s@macro-llamadaEntranteUC:4] Set(“SIP/ISP\_SIPtrunk-00000000”, “\_\_TRANSFER\_CONTEXT=station\_transferUC”) in new stack  
– Executing [s@macro-llamadaEntranteUC:5] Set(“SIP/ISP\_SIPtrunk-00000000”, “NUMCALLED=25988”) in new stack  
– Executing [s@macro-llamadaEntranteUC:6] Set(“SIP/ISP\_SIPtrunk-00000000”, “NUMCALLER=37233”) in new stack  
– Executing [s@macro-llamadaEntranteUC:7] GotoIf(“SIP/ISP\_SIPtrunk-00000000”, “0?desconegut:conegut”) in new stack  
– Goto (macro-llamadaEntranteUC,s,10)  
– Executing [s@macro-llamadaEntranteUC:10] GotoIf(“SIP/ISP\_SIPtrunk-00000000”, “0?addZeroPrefix”) in new stack  
– Executing [s@macro-llamadaEntranteUC:11] Goto(“SIP/ISP\_SIPtrunk-00000000”, “s,nextZeroPrefix”) in new stack  
– Goto (macro-llamadaEntranteUC,s,13)  
– Executing [s@macro-llamadaEntranteUC:13] Set(“SIP/ISP\_SIPtrunk-00000000”, “\_UCUSER=25988”) in new stack  
– Executing [s@macro-llamadaEntranteUC:14] Set(“SIP/ISP\_SIPtrunk-00000000”, “CDR(PRIVACY-ID)=“Privacy: off””) in new stack  
– Executing [s@macro-llamadaEntranteUC:15] Set(“SIP/ISP\_SIPtrunk-00000000”, “CALLERID(all)=37233 \<37233\>”) in new stack  
– Executing [s@macro-llamadaEntranteUC:16] SIPAddHeader(“SIP/ISP\_SIPtrunk-00000000”, “P-Asserted-Identity: 37233 sip:37233@mydomain.com”) in new stack  
– Executing [s@macro-llamadaEntranteUC:17] GotoIf(“SIP/ISP\_SIPtrunk-00000000”, “0?privacy:privacyoff”) in new stack  
– Goto (macro-llamadaEntranteUC,s,22)  
– Executing [s@macro-llamadaEntranteUC:22] SIPAddHeader(“SIP/ISP\_SIPtrunk-00000000”, “Remote-Party-ID: 37233 sip:37233@mydomain.com”) in new stack  
– Executing [s@macro-llamadaEntranteUC:23] Dial(“SIP/ISP\_SIPtrunk-00000000”, “SIP/PROXY-out/25988,t”) in new stack  
== Using SIP RTP TOS bits 184  
== Using SIP RTP CoS mark 5  
– Called SIP/PROXY-out/25988  
– SIP/PROXY-out-00000001 is ringing  
– SIP/PROXY-out-00000001 answered SIP/ISP\_SIPtrunk-00000000  
– Channel SIP/PROXY-out-00000001 joined ‘simple\_bridge’ basic-bridge   
– Channel SIP/ISP\_SIPtrunk-00000000 joined ‘simple\_bridge’ basic-bridge   
\> 0x7f747800b0b0 – Probation passed - setting RTP source address to 1.1.1.1:10748  
\> 0x7f746800adc0 – Probation passed - setting RTP source address to 2.2.2.2.:30122  
– Started music on hold, class ‘default’, on channel ‘SIP/ISP\_SIPtrunk-00000000’  
[May 25 11:27:50] NOTICE[19960][C-00000000]: chan\_sip.c:23978 handle\_response\_notify: Got OK on REFER Notify message

This same scenario works fine with Asterisk 11 and with the same config files.

```
-- Executing [25988@incoming:1] Macro("SIP/ISP_SIPtrunk-0000000a", "llamadaEntranteUC,25988,37233") in new stack
-- Executing [s@macro-llamadaEntranteUC:1] NoOp("SIP/ISP_SIPtrunk-0000000a", "CallingPress --1-- caller id --"37233" <37233>--") in new stack
-- Executing [s@macro-llamadaEntranteUC:2] Set("SIP/ISP_SIPtrunk-0000000a", "TRANSFER_CONTEXT=station_transferUC") in new stack
-- Executing [s@macro-llamadaEntranteUC:3] Set("SIP/ISP_SIPtrunk-0000000a", "_TRANSFER_CONTEXT=station_transferUC") in new stack
-- Executing [s@macro-llamadaEntranteUC:4] Set("SIP/ISP_SIPtrunk-0000000a", "__TRANSFER_CONTEXT=station_transferUC") in new stack
-- Executing [s@macro-llamadaEntranteUC:5] Set("SIP/ISP_SIPtrunk-0000000a", "NUMCALLED=25988") in new stack
-- Executing [s@macro-llamadaEntranteUC:6] Set("SIP/ISP_SIPtrunk-0000000a", "NUMCALLER=37233") in new stack
-- Executing [s@macro-llamadaEntranteUC:7] GotoIf("SIP/ISP_SIPtrunk-0000000a", "0?desconegut:conegut") in new stack
-- Goto (macro-llamadaEntranteUC,s,10)
-- Executing [s@macro-llamadaEntranteUC:10] GotoIf("SIP/ISP_SIPtrunk-0000000a", "0?addZeroPrefix") in new stack
-- Executing [s@macro-llamadaEntranteUC:11] Goto("SIP/ISP_SIPtrunk-0000000a", "s,nextZeroPrefix") in new stack
-- Goto (macro-llamadaEntranteUC,s,13)
-- Executing [s@macro-llamadaEntranteUC:13] Set("SIP/ISP_SIPtrunk-0000000a", "_UCUSER=25988") in new stack
-- Executing [s@macro-llamadaEntranteUC:14] Set("SIP/ISP_SIPtrunk-0000000a", "CDR(PRIVACY-ID)="Privacy: off"") in new stack
-- Executing [s@macro-llamadaEntranteUC:15] Set("SIP/ISP_SIPtrunk-0000000a", "CALLERID(all)=37233 <37233>") in new stack
-- Executing [s@macro-llamadaEntranteUC:16] SIPAddHeader("SIP/ISP_SIPtrunk-0000000a", "P-Asserted-Identity: 37233 <sip:37233@mydomain.com>") in new stack
-- Executing [s@macro-llamadaEntranteUC:17] GotoIf("SIP/ISP_SIPtrunk-0000000a", "0?privacy:privacyoff") in new stack
-- Goto (macro-llamadaEntranteUC,s,22)
-- Executing [s@macro-llamadaEntranteUC:22] SIPAddHeader("SIP/ISP_SIPtrunk-0000000a", "Remote-Party-ID: 37233 <sip:37233@mydomain.com>") in new stack
-- Executing [s@macro-llamadaEntranteUC:23] Dial("SIP/ISP_SIPtrunk-0000000a", "SIP/PROXY-out/25988,,t") in new stack

```

== Using SIP RTP TOS bits 184  
== Using SIP RTP CoS mark 5  
– Called SIP/PROXY-out/25988  
– SIP/PROXY-out-0000000b is ringing  
– SIP/PROXY-out-0000000b answered SIP/ISP\_SIPtrunk-0000000a  
\> 0x7f2b3c006da0 – Probation passed - setting RTP source address to 1.1.1.1:10742  
\> 0x2c6cbf0 – Probation passed - setting RTP source address to 2.2.2.2:35120  
– Started music on hold, class ‘default’, on SIP/ISP\_SIPtrunk-0000000a  
– Stopped music on hold on SIP/ISP\_SIPtrunk-0000000a  
== Spawn extension (station\_transferUC, u6-676, 1) exited non-zero on ‘SIP/ISP\_SIPtrunk-0000000a’ in macro ‘llamadaEntranteUC’  
== Spawn extension (station\_transferUC, u6-676, 1) exited non-zero on ‘SIP/ISP\_SIPtrunk-0000000a’  
– Executing [u6-676@station\_transferUC:1] Macro(“SIP/ISP\_SIPtrunk-0000000a”, “transferUCAAi,u6-676,37233,”) in new stack  
– Executing [s@macro-transferUCAAi:1] NoOp(“SIP/ISP\_SIPtrunk-0000000a”, “Transfer call 37233 to u6-676. Prefix . GWFailover . --UCUser: 25988–”) in new stack  
– Executing [s@macro-transferUCAAi:2] Set(“SIP/ISP\_SIPtrunk-0000000a”, “NUMDESTI=u6-676”) in new stack  
– Executing [s@macro-transferUCAAi:3] Set(“SIP/ISP\_SIPtrunk-0000000a”, “NUMORIGEN=37233”) in new stack  
– Executing [s@macro-transferUCAAi:4] Set(“SIP/ISP\_SIPtrunk-0000000a”, “CALLEDPREFIX=”) in new stack  
– Executing [s@macro-transferUCAAi:5] Set(“SIP/ISP\_SIPtrunk-0000000a”, “GWFAILOVER=”) in new stack  
– Executing [s@macro-transferUCAAi:6] Dial(“SIP/ISP\_SIPtrunk-0000000a”, “SIP/NB-out/u6-676,t”) in new stack  
== Using SIP RTP TOS bits 184  
== Using SIP RTP CoS mark 5  
– Called SIP/NB-out/u6-676  
– SIP/NB-out-0000000c answered SIP/ISP\_SIPtrunk-0000000a  
\> 0x2c79f50 – Probation passed - setting RTP source address to 2.2.2.2:40104

Any idea why Asterisk 13 don’t execute the TRASNFER\_CONTEXT code and send the INVITE with Replaces?

Thanks for your help.

Jose
