Call routing, 407s

I have a fairly specific requirement, which I hope Asterisk (with or without the help of SER) can solve.

I have a media server which runs IVR and voice recog applications. Those applications can and do transfer inbound calls to outbound calls.

As the ports on this media server are licensed per port it get’s expense when a lot of ports are in use.

I want Asterisk and/or SER to take the load off by fronting the media server and when an inbound call is to be transfered out to an outbound trunk Asterisk and not the media server has the 2 calls, freeing the ports on the media server.

After much blood sweat, tears and strong coffee I managed to get Asterisk to bridge the calls during transfer.

However, the only method of transfer I can get to work is “Blind”. As soon as Asterisk accepts the “SIP REFER” it disconnects the media server from the call. Attempting to set the transfer method to “Consultation” or forcing “Answer when connected only” are ignored Asterisk has already torn down the calls and bridged the user to the new ringing number.

For some applications this is fine. However many applications require the calls stay within the media server until answered, allowing the application to pick up control of failed calls, busy calls etc (standard 3 way PBX calling), or even allow the application to wait on the call completing entirely.

The media platform supports these transfers as “Blind”; what I have working, “Consultation”; bridge only when answered and “Bridge”, where the bridging happens in the media server and it remains in control.

The problem is when I attempt “Bridge” in the media server it issues an INVITE, like:

INVITE sip:103@10.0.4.147:5060 SIP/2.0
Via: SIP/2.0/UDP 10.0.2.136:5060;branch=z9hG4bKb575f8a029f9a1
From: sip:paul@10.0.4.147;tag=C1431100-8D08-8469-16BD-D1FEF9F65EF8
To: <sip:103@10.0.4.147:5060>[/code]

10.0.4.147 = Asterisk server
10.0.2.136 = Media server

103 = Asterisk extension   (Intended target of transfer)
paul = Asterisk SIP 'friend'  (Origin of call)
vgp = Asterisk SIP 'friend'  (Media Server call transfer'er)
(All are registered)

Name/username              Host            Dyn Nat ACL Port     Status
vgp/vgp                    10.0.2.136       D       A  5060     Unmonitored
test/test                  10.0.6.44        D          5062     Unmonitored
paul/paul                  10.0.6.44        D          1668     Unmonitored
103                        (Unspecified)               5060     Unmonitored
102                        (Unspecified)               5060     Unmonitored
101                        (Unspecified)               5060     Unmonitored

Asterisk simply throws back a 407, as so:
[code]
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 10.0.2.136:5060;branch=z9hG4bKb575f8a029f9a1;received=10.0.2.136
From: sip:paul@10.0.4.147;tag=C1431100-8D08-8469-16BD-D1FEF9F65EF8
To: <sip:103@10.0.4.147:5060>;tag=as06a8f8cd
[/code]


sip.conf
[code][general]
context=internal
srvlookup=yes

[paul]
type=friend
secret=xxx
qualify=no
nat=no
host=dynamic
canreinvite=yes
context=internal

[test]
type=friend
secret=xxx
qualify=no
nat=no
host=dynamic
canreinvite=yes
context=internal

[vgp]
type=friend
secret=xxx
qualify=no
nat=no
host=dynamic
permit=10.0.2.136/8
canreinvite=no
context=internal
insecure=very

extensions.conf

[code][general]
allowanonymousproxy=yes
allowanonymoussipcalls=yes

[incoming]
exten => s,1,Answer( )
exten => s,2,Background(vm-extension)
exten => 101,1,Dial(SIP/paul,10)
exten => 101,2,Playback(vm-nobodyavail)
exten => 102,1,Dial(SIP/stu,10)
exten => 102,2,Playback(vm-nobodyavail)

exten => i,1,Playback(pbx-invalid)
exten => i,2,Goto(incoming,s,1)
exten => t,1,Playback(vm-goodbye)
exten => t,2,Hangup()

[internal]
exten => 101,1,Dial(SIP/paul,20,rtT)
exten => 101,n,VoiceMail(u101@internal)
exten => 101,102,VoiceMail(b101@internal)

exten => 103,1,Dial(SIP/test,10,r)

exten => 201,1,Dial(SIP/rik@middlesborough)

exten => 202,1,Dial(SIP/paulxfertest@middlesborough)

exten => 203,1,Dial(SIP/pauljointest@middlesborough)

[/code]

The only thing I suspect is that while the Media Server is registering with Asterisk as vgp, it is a different setting on the box to select it’s “Local SIP user”, which I also set to vgp. The two may not be connected, which is why I added the:

permit=10.0.2.136 line.

Any ideas, hints, tips?

Thanks
Paul

I meant to add, if I attempt a direct call out from the Media server to an Asterisk extension the call is accepted as normal. It is only when the “From:” header in the SIP is not the media server itself, but another Asterisk extension that things to wayward.

Is this anything to do with:

(a) Asterisk not being a true SIP Proxy.

(b) Asterisk disconnecting calls that loop back through itself?

Is 10.0.2.136 is a Sip express router ?

No, 10.0.2.136 is a Genisys VoiceGenie Server. It usually behaves just like a bunch of SIP phones. For example there are 2 applications in use…

paulxfertest@ – works Blind (REFER) transfer
pauljointest@ – doesn’t work, initiates an outbound call to extension 103.

I think this may be causing an issue also, as I am dialing

Dial(SIP/paulxfertest@middlesborough)
or
Dial(SIP/pauljointest@middlesborough)

Instead of:

Dial(SIP/vgp1)
Dial(SIP/vgp2)

and registering these as separate asterisk ‘friends’. Don’t know if that would help at all.

I’m fairly baffled at the moment.

Thanks

Paul

The nub of the problem is this…

I don’t see why Asterisk considers this a Proxy request. It is from an Asterisk extension/friend, to an Asterisk extension/friend, via an Asterisk extension/friend. No proxying at all! All are registered with Asterisk.

[code]<— SIP read from 10.0.2.136:5060 —>
INVITE sip:103@10.0.4.147 SIP/2.0
Via: SIP/2.0/UDP 10.0.2.136:5060;branch=z9hG4bKb45433f02b01e8
From: sip:paul@10.0.4.147;tag=C1431100-8D08-DE47-DBB8-1DF581E49E68
To: sip:103@10.0.4.147
Max-Forwards: 70
CSeq: 1 INVITE
Call-ID: C1431100-8D08-23E8-3516-22CF5BF36071-5060@10.0.2.136
Contact: sip:vgp@10.0.2.136:5060
Content-Length: 218
Content-Type: application/sdp
Supported: timer

v=0
o=VoiceGenie 1073964351 1 IN IP4 10.0.2.136
s=phone-call
c=IN IP4 10.0.2.136
t=0 0
m=audio 1154 RTP/AVP 0 8 101
a=rtpmap:0 pcmu/8000
a=rtpmap:8 pcma/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15

<------------->
— (11 headers 10 lines) —
Sending to 10.0.2.136 : 5060 (no NAT)
Using INVITE request as basis request - C1431100-8D08-23E8-3516-22CF5BF36071-5060@10.0.2.136

<— Reliably Transmitting (no NAT) to 10.0.2.136:5060 —>
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 10.0.2.136:5060;branch=z9hG4bKb45433f02b01e8;received=10.0.2.136
From: sip:paul@10.0.4.147;tag=C1431100-8D08-DE47-DBB8-1DF581E49E68
To: sip:103@10.0.4.147;tag=as18029604
Call-ID: C1431100-8D08-23E8-3516-22CF5BF36071-5060@10.0.2.136
CSeq: 1 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Proxy-Authenticate: Digest algorithm=MD5, realm=“asterisk”, nonce="56a44fa2"
Content-Length: 0
[/code]

I fixed it.
:smiling_imp:

In channels/chan_sip.c

static enum check_auth_result check_auth(struct sip_pvt *p, struct sip_request *req, const char *username, const char *secret, const char *md5secret, int sipmethod, char *uri, enum xmittype reliable, int ignore)
I forced the function to always return 0 for success. Now the call is routed through correctly.

Maybe I’ll go back and narrow it down a little to just the particular cause of my 407 and hack that out.

My system will not require auth anyway, it will be on a protected network with just Asterisk and the Media server.