Call drops using Transfer in FastAGI

We have to transfer a call from our IVR. The IVR is a FastAGI application and we are transferring to a SIP extension. If we use the Dial application, then the transfer happens. The problem with Dial is that it waits until the call is actually ended (between caller and agent.) But if we use the Transfer application, then

a) transfer doesn’t happens,
b) as soon as the AGI ends, the call is dropped (in actual, we want that it to be like, do transfer, return from the AGI application)

This is the log from SIP debug:
http://pastie.org/6458319 (Line 64 is where we do the Transfer)



<------------>
    -- Executing [111@access:1] Answer("SIP/100-00000019", "") in new stack
Audio is at 192.168.3.143 port 15242
Adding codec 0x2 (gsm) to SDP
Adding codec 0x4 (ulaw) to SDP
Adding codec 0x8 (alaw) to SDP
Adding non-codec 0x1 (telephone-event) to SDP

<--- Reliably Transmitting (NAT) to 192.168.3.108:49908 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.3.108:49908;branch=z9hG4bK-d8754z-2f18b213272e9942-1---d8754z-;received=192.168.3.108;rport=49908
From: "100"<sip:100@192.168.3.143:5060>;tag=f679b43e
To: <sip:111@192.168.3.143:5060>;tag=as34fff437
Call-ID: YWViZjJkZTY2OGM2ZDk2NDg1NzVlYmMxNzE0ZTc0YjQ.
CSeq: 2 INVITE
Server: Asterisk PBX 1.6.2.22
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO
Supported: replaces, timer
ontact: <sip:111@192.168.3.143>
Content-Type: application/sdp
Content-Length: 286

v=0
o=root 1153025468 1153025468 IN IP4 192.168.3.143
s=Asterisk PBX 1.6.2.22
c=IN IP4 192.168.3.143
t=0 0
m=audio 15242 RTP/AVP 3 0 8 101
a=rtpmap:3 GSM/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv

<------------>
    -- Executing [111@access:2] AGI("SIP/100-00000019", "agi://192.168.3.108/testtreatment,inbound") in new stack
[Mar 12 00:10:25] NOTICE[4336]: channel.c:3168 __ast_read: Dropping incompatible voice frame on SIP/100-00000019 of format ulaw since our native format has changed to 0x2 (gsm)

<--- SIP read from UDP:192.168.3.108:49908 --->
ACK sip:111@192.168.3.143 SIP/2.0
Via: SIP/2.0/UDP 192.168.3.108:49908;branch=z9hG4bK-d8754z-d76fce337129f122-1---d8754z-;rport
Max-Forwards: 70
Contact: <sip:100@192.168.3.108:49908;rinstance=edb699ec3fd66cda>
To: <sip:111@192.168.3.143:5060>;tag=as34fff437
From: "100"<sip:100@192.168.3.143:5060>;tag=f679b43e
Call-ID: YWViZjJkZTY2OGM2ZDk2NDg1NzVlYmMxNzE0ZTc0YjQ.
CSeq: 2 ACK
User-Agent: 3CXPhone 6.0.25732.0
Authorization: Digest username="100",realm="asterisk",nonce="78183468",uri="sip:111@192.168.3.143:5060",response="11ad684ceefaa124228c7f472e8d1286",algorithm=MD5
Content-Length: 0


<------------->
--- (11 headers 0 lines) ---
    -- Playing 'hello-world' (escape_digits=0123456789*#) (sample_offset 0)

<--- SIP read from UDP:192.168.3.108:49908 --->



<------------->
    -- AGI Script Executing Application: (Transfer) Options: (SIP/102)
set_destination: Parsing <sip:100@192.168.3.108:49908;rinstance=edb699ec3fd66cda> for address/port to send to
set_destination: set destination to 192.168.3.108, port 49908
Reliably Transmitting (NAT) to 192.168.3.108:49908:
REFER sip:100@192.168.3.108:49908;rinstance=edb699ec3fd66cda SIP/2.0
Via: SIP/2.0/UDP 192.168.3.143:5060;branch=z9hG4bK6c498f4d;rport
Max-Forwards: 70
From: <sip:111@192.168.3.143:5060>;tag=as34fff437
To: "100"<sip:100@192.168.3.143:5060>;tag=f679b43e
Contact: <sip:111@192.168.3.143>
Call-ID: YWViZjJkZTY2OGM2ZDk2NDg1NzVlYmMxNzE0ZTc0YjQ.
CSeq: 102 REFER
User-Agent: Asterisk PBX 1.6.2.22
Refer-To: <sip:102@192.168.3.143:5060>
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO
Supported: replaces, timer
Referred-By: <sip:111@192.168.3.143>
Content-Length: 0


---
Retransmitting #1 (NAT) to 192.168.3.108:49908:
REFER sip:100@192.168.3.108:49908;rinstance=edb699ec3fd66cda SIP/2.0
Via: SIP/2.0/UDP 192.168.3.143:5060;branch=z9hG4bK6c498f4d;rport
Max-Forwards: 70
From: <sip:111@192.168.3.143:5060>;tag=as34fff437
To: "100"<sip:100@192.168.3.143:5060>;tag=f679b43e
Contact: <sip:111@192.168.3.143>
Call-ID: YWViZjJkZTY2OGM2ZDk2NDg1NzVlYmMxNzE0ZTc0YjQ.
CSeq: 102 REFER
User-Agent: Asterisk PBX 1.6.2.22
Refer-To: <sip:102@192.168.3.143:5060>
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO
Supported: replaces, timer
Referred-By: <sip:111@192.168.3.143>
Content-Length: 0


---
    -- <SIP/100-00000019>AGI Script agi://192.168.3.108/testtreatment completed, returning 0
    -- Auto fallthrough, channel 'SIP/100-00000019' status is 'UNKNOWN'
Scheduling destruction of SIP dialog 'YWViZjJkZTY2OGM2ZDk2NDg1NzVlYmMxNzE0ZTc0YjQ.' in 32000 ms (Method: ACK)
set_destination: Parsing <sip:100@192.168.3.108:49908;rinstance=edb699ec3fd66cda> for address/port to send to
set_destination: set destination to 192.168.3.108, port 49908
Reliably Transmitting (NAT) to 192.168.3.108:49908:
BYE sip:100@192.168.3.108:49908;rinstance=edb699ec3fd66cda SIP/2.0
Via: SIP/2.0/UDP 192.168.3.143:5060;branch=z9hG4bK40406ad1;rport
Max-Forwards: 70
From: <sip:111@192.168.3.143:5060>;tag=as34fff437
To: "100"<sip:100@192.168.3.143:5060>;tag=f679b43e
Call-ID: YWViZjJkZTY2OGM2ZDk2NDg1NzVlYmMxNzE0ZTc0YjQ.
CSeq: 103 BYE
User-Agent: Asterisk PBX 1.6.2.22
X-Asterisk-HangupCause: Unknown
X-Asterisk-HangupCauseCode: 0
Content-Length: 0


---

<--- SIP read from UDP:192.168.3.108:49908 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.3.143:5060;branch=z9hG4bK40406ad1;rport=5060
Contact: <sip:100@192.168.3.108:49908;rinstance=edb699ec3fd66cda>
To: "100"<sip:100@192.168.3.143:5060>;tag=f679b43e
From: <sip:111@192.168.3.143:5060>;tag=as34fff437
Call-ID: YWViZjJkZTY2OGM2ZDk2NDg1NzVlYmMxNzE0ZTc0YjQ.
CSeq: 103 BYE
User-Agent: 3CXPhone 6.0.25732.0
Content-Length: 0


<------------->
--- (9 headers 0 lines) ---
SIP Response message for INCOMING dialog BYE arrived
Retransmitting #2 (NAT) to 192.168.3.108:49908:
REFER sip:100@192.168.3.108:49908;rinstance=edb699ec3fd66cda SIP/2.0
Via: SIP/2.0/UDP 192.168.3.143:5060;branch=z9hG4bK6c498f4d;rport
Max-Forwards: 70
From: <sip:111@192.168.3.143:5060>;tag=as34fff437
To: "100"<sip:100@192.168.3.143:5060>;tag=f679b43e
Contact: <sip:111@192.168.3.143>
Call-ID: YWViZjJkZTY2OGM2ZDk2NDg1NzVlYmMxNzE0ZTc0YjQ.
CSeq: 102 REFER
User-Agent: Asterisk PBX 1.6.2.22
Refer-To: <sip:102@192.168.3.143:5060>
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO
Supported: replaces, timer
Referred-By: <sip:111@192.168.3.143>
Content-Length: 0


---

<--- SIP read from UDP:192.168.3.108:5060 --->



<------------->

<--- SIP read from UDP:192.168.3.108:49908 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.3.143:5060;branch=z9hG4bK6c498f4d;rport=5060
To: "100"<sip:100@192.168.3.143:5060>;tag=f679b43e
From: <sip:111@192.168.3.143:5060>;tag=as34fff437
Call-ID: YWViZjJkZTY2OGM2ZDk2NDg1NzVlYmMxNzE0ZTc0YjQ.
CSeq: 102 REFER
Content-Length: 0


<------------->
--- (7 headers 0 lines) ---
SIP Response message for INCOMING dialog REFER arrived

I’m using Asterisk version 1.6.2.22. The caller is a SIP extension (right now) and using 3CX phone and the transfer agent (SIP extension) is using X-Lite.

Please help.

  1. Support for REFER is somewhat flakey, in particular if anything goes wrong.

  2. Asterisk is retransmitting the REFER because it is getting no response. That suggests a broken implementation in the remote system, as you should get a rejection, at the very least.

What should I do then? Do you suggest something to test?

The REMOTE end (client) is X-Lite. (Also tested with 3CX, but same result.)