Inbound SIP call not routing to the defined context

I am having a problem where an inbound call to a SIP ATA is not routing to the defined context.

The set up is:

SIP based ATA
Asterisk 1.2.5
SIP based phone

I place a call from the PSTN the SIP ATA answers and then routes the call to the context defined in the general section and not the context defined for the device. If I remove the context definition in the General section then the Asterisk tries to route the call to the default context and not the one defined for the device.

The inbound device in question is
[Excel_Max_1]

This should deliver the calls to the context [excel_max_inbound]

It actually delivers the call to [nact_utah]

The config files are as follows: (I striped all but the basic config out for testing)

sip.conf
[general]
bindaddr = 0.0.0.0
port = 5060
context = nact_utah 
disallow = all
allow = ulaw
allow = alaw
allow = g729
allow = gsm
bindport = 5060 ; Port to listen on

[1002]
type = peer
host = dynamic
username = 1002
secret = 1002
mailbox = 1002@nact_utah
callerid = "Bob Jones" <8018021461>

[1461]
type = peer
host = dynamic
username = 1461
secret = 1461
mailbox = 1461@nact_utah
callerid = <1461>

[1003]
type = friend
host = dynamic
username = 1003
secret = 1003
mailbox = 1003@nact_utah
callerid = "Jane Smith" <8018021460>

[1001]
type = peer
host = dynamic
username = 1001
secret = 1001
mailbox = 1001@nact_utah
callerid = "Bob Smith" <1001>

[Excel_Max_1]
type = friend
host = xxx.xxx.xxx.xxx
context = excel_max_inbound

[1000]
type = peer
host = dynamic
username = 1000
secret = 1000
mailbox = 1000@nact_utah
callerid = "Bob Jones" <1000>

[scott_test]
type = friend
host = dynamic
username = scott_test
secret = scott_test
callerid = 8018021415
nat = yes

extensions.conf
[general]
static=yes
writeprotect=no
autofallthrough=yes
clearglobalvars=no
priorityjumping=no

[globals]
CONSOLE=Console/dsp
IAXINFO=guest

LD_TRUNK=SIP/Excel_Max_1
TRUNK=SIP/Excel_Max_1

RING_STD=20
RING_EXTENDED=35
EXT_OPTIONS=Ttr

[tollfree]
; Long distance context accessed through trunk interface

exten => _1800NXXXXXX,1,Dial(${TRUNK}/${EXTEN:0})

exten => _1888NXXXXXX,1,Dial(${TRUNK}/${EXTEN:0})

exten => _1877NXXXXXX,1,Dial(${TRUNK}/${EXTEN:0})

exten => _1866NXXXXXX,1,Dial(${TRUNK}/${EXTEN:0})

[North_American]
exten => _1NXXNXXXXXX,1,Dial(${TRUNK}/${EXTEN:0})

[International]
exten => _011.,1,Dial(${TRUNK}/${EXTEN:0})

[incoming]
exten => s,1,Answer
exten => s,n,Goto(1003,1)

[excel_max_inbound]
;include => nact_utah

;exten => _X.,1,Answer
;exten => _X.,n,Goto(nact_utah,1461,1)

exten => 8018021461,1,Answer
exten => 8018021461,n,Goto(1461,1)


[nact_utah]
include => tollfree
include => North_American
include => International
;include => excel_max_inbound

exten => 1461,1,Dial(SIP/1461,${RING_STD},${EXT_OPTIONS})
exten => 1461,n,Voicemail(u1461)
exten => 1461,n,Voicemail(b1461)

exten => 1000,1,Dial(SIP/1000,${RING_STD},${EXT_OPTIONS})
exten => 1000,n,Voicemail(u1000)
exten => 1000,n,Voicemail(b1000)

exten => 1001,1,Dial(SIP/1001,${RING_STD},${EXT_OPTIONS})
exten => 1001,n,Voicemail(u1001)
exten => 1001,n,Voicemail(b1001)

exten => 1002,1,Dial(SIP/1002,${RING_STD},${EXT_OPTIONS})
exten => 1002,n,Voicemail(u1002)
exten => 1002,n,Voicemail(b1002)

exten => 1003,1,Dial(SIP/1003,${RING_STD},${EXT_OPTIONS})
exten => 1003,n,Voicemail(u1003)
exten => 1003,n,Voicemail(b1003)

exten => 1010,1,Dial(IAX2/scott_test,${RING_STD},${EXT_OPTIONS})
exten => 1010,n,Voicemail(u1010)
exten => 1010,n,Voicemail(b1010)

exten => 1011,1,Dial(SIP/scott_test,${RING_STD},${EXT_OPTIONS})
exten => 1011,n,Voicemail(u1010)
exten => 1011,n,Voicemail(b1010)

; Voicemail access extension
exten => 6000,1,VoicemailMain
exten => 6000,2,Hangup

; Conference rooms
exten => 2000,1,Meetme(2000|Mc)

The debug from the call is:


Sending to 208.187.44.30 : 5060 (non-NAT)
Found RTP audio format 0
Peer audio RTP is at port 208.187.44.31:13000
Capabilities: us - 0x10e (gsm|ulaw|alaw|g729), peer - audio=0x4 (ulaw)/video=0x0 (nothing), combined - 0x4 (ulaw)
Non-codec capabilities: us - 0x1 (telephone-event), peer - 0x0 (nothing), combined - 0x0 (nothing)
Looking for 8018021461 in nact_utah (domain 208.187.44.53)
Reliably Transmitting (no NAT) to 208.187.44.30:5060:
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 208.187.44.30;received=208.187.44.30
From: 00000000<sip:00000000@208.187.44.30:5060>;tag=1719700115f63
To: 8018021461<sip:8018021461@208.187.44.53:5060>;tag=as7e75be68
Call-ID: EXCEL-CSP255.6b7.89955.690@208.187.44.30
CSeq: 1 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Contact: <sip:8018021461@208.187.44.53>
Content-Length: 0


---
Destroying call 'EXCEL-CSP255.6b7.89955.690@208.187.44.30'
Sending to 208.187.44.30 : 5060 (non-NAT)
Found RTP audio format 0
Peer audio RTP is at port 208.187.44.31:12996
Capabilities: us - 0x10e (gsm|ulaw|alaw|g729), peer - audio=0x4 (ulaw)/video=0x0 (nothing), combined - 0x4 (ulaw)
Non-codec capabilities: us - 0x1 (telephone-event), peer - 0x0 (nothing), combined - 0x0 (nothing)
Looking for 8018021461 in nact_utah (domain 208.187.44.53)
Reliably Transmitting (no NAT) to 208.187.44.30:5060:
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 208.187.44.30;received=208.187.44.30
From: 00000000<sip:00000000@208.187.44.30:5060>;tag=1711872615f63
To: 8018021461<sip:8018021461@208.187.44.53:5060>;tag=as648d74fc
Call-ID: EXCEL-CSP255.6af.89955.740@208.187.44.30
CSeq: 1 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Contact: <sip:8018021461@208.187.44.53>
Content-Length: 0


---
Destroying call 'EXCEL-CSP255.6af.89955.740@208.187.44.30'
Sending to 208.187.44.30 : 5060 (non-NAT)
Found RTP audio format 0
Peer audio RTP is at port 208.187.44.31:12992
Capabilities: us - 0x10e (gsm|ulaw|alaw|g729), peer - audio=0x4 (ulaw)/video=0x0 (nothing), combined - 0x4 (ulaw)
Non-codec capabilities: us - 0x1 (telephone-event), peer - 0x0 (nothing), combined - 0x0 (nothing)
Looking for 8018021461 in nact_utah (domain 208.187.44.53)
Reliably Transmitting (no NAT) to 208.187.44.30:5060:
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 208.187.44.30;received=208.187.44.30
From: 00000000<sip:00000000@208.187.44.30:5060>;tag=1703662815f63
To: 8018021461<sip:8018021461@208.187.44.53:5060>;tag=as6e65e179
Call-ID: EXCEL-CSP255.6a7.89955.790@208.187.44.30
CSeq: 1 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Contact: <sip:8018021461@208.187.44.53>
Content-Length: 0


---
Destroying call 'EXCEL-CSP255.6a7.89955.790@208.187.44.30'
Sending to 208.187.44.30 : 5060 (non-NAT)
Found RTP audio format 0
Peer audio RTP is at port 208.187.44.31:12988
Capabilities: us - 0x10e (gsm|ulaw|alaw|g729), peer - audio=0x4 (ulaw)/video=0x0 (nothing), combined - 0x4 (ulaw)
Non-codec capabilities: us - 0x1 (telephone-event), peer - 0x0 (nothing), combined - 0x0 (nothing)
Looking for 8018021461 in nact_utah (domain 208.187.44.53)
Reliably Transmitting (no NAT) to 208.187.44.30:5060:
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 208.187.44.30;received=208.187.44.30
From: 00000000<sip:00000000@208.187.44.30:5060>;tag=1663969915f63
To: 8018021461<sip:8018021461@208.187.44.53:5060>;tag=as200f50c4
Call-ID: EXCEL-CSP255.67f.89955.870@208.187.44.30
CSeq: 1 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Contact: <sip:8018021461@208.187.44.53>
Content-Length: 0


---
Destroying call 'EXCEL-CSP255.67f.89955.870@208.187.44.30'

first things first, you shouldn’t give access to your outbound contexts for incoming calls. just think what could happen with a config error !

Asterisk is looking for 8018021461 in [nact_utah] but it’s not there, it’s an extension defined in [excel_max_inbound]. it’s working properly, but configured wrongly.

So if I did this wrong then I am missing something fundemental in my understanding.

What I want to accomplish is to have the [excel_max_inbound] handle all inbound calls from this sip device and then forward them based on the number dialed. The Excel device will have several PRI’s with DID pools on it.

If it is a DID tht is recognized then I want to Goto the approriate extension in the [nact_utah] context.

The reason you see the “include” in the outbound context is that is the only work around I could find to make this work for the moment.

So if I did configure this wrong, which I assumed I already had, how can I configure this differently to work as indicated above.

One additional question/comment. If you note the sip.conf config for the Excel_Max_1 this specifies to use the [excel_max_inbound] context and not the [nact_utah] context so my question is back to why is it using the default context and not the one specified, am I missing something here?

Well obviously I am missing something :wink:

I modified the sip.conf so that the device in question is configured as follows:

[excel_1_inbound]
type = user
host = 208.187.44.30
context = excel_inbound
[excel_1_outbound]

Note that I changed the context in extensions.conf to [excel_inbound].

The problem is still the same, when the excel device delivers the call it is delivering it to the [nact_utah] and not the [excel_inbound] as follows:

--- (13 headers 6 lines)---
Using INVITE request as basis request - EXCEL-CSP255.757.111824.900@208.187.44.30
Sending to 208.187.44.30 : 5060 (non-NAT)
Found no matching peer or user for '208.187.44.30:1049'
Found RTP audio format 0
Peer audio RTP is at port 208.187.44.31:12952
Capabilities: us - 0x10e (gsm|ulaw|alaw|g729), peer - audio=0x4 (ulaw)/video=0x0 (nothing), combined - 0x4 (ulaw)
Non-codec capabilities: us - 0x1 (telephone-event), peer - 0x0 (nothing), combined - 0x0 (nothing)
Looking for 8018021461 in nact_utah (domain 208.187.44.53) <==N notice the [nact_utah] and not [excel_inbound]
Reliably Transmitting (no NAT) to 208.187.44.30:5060:
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 208.187.44.30;received=208.187.44.30
From: 00000000<sip:00000000@208.187.44.30:5060>;tag=187964301b4d0
To: 8018021461<sip:8018021461@208.187.44.53:5060>;tag=as683df5b4
Call-ID: EXCEL-CSP255.757.111824.900@208.187.44

It seems to be picking up this value from the default definition. If I remove the default definition then it tries to look in [default] for the answer.

given that the SIP debug indicates that it can’t find a peer or user for the inbound connection, it’s defaulting to the context= in the [general] section of sip.conf.

you could “fix” this, but it’s not really “broken” and why not just define your inbound “extensions” in the default incoming context, then set each one to either Dial the appropriate device(s) or Goto(context,extension,priority). there’s no need to include your internal contexts in the incoming context.

I follow what you are saying but I don’t understand why I can’t have a particular sip device forward to a specific context for inbound calls. Is this a limitation or is there anotherway to accomplish this.

When working iwth zaptel devices you can forward to a specific context, it seems like this should be possible for sip and other devices or am I assume capabilites that don’t exist.

(havent read the rest of the thread, might catch up later)

that is completely possible. In sip.conf for each entry you define a context= and the phone is in that context. It can then only dial any exten in its context, or anything in contexts included in its context and any thing included in those contexts.

ie, if you have a sip provider in context1

[context1]
include => context2

[context2]
include => context3

[context3]
(things that shouldn’t be included in an incoming context)

they will be able to dial the (things)

Keep in mind you can always override this.
For example, say you have a sip provider, and many phones as sip friends.

you can put the provider in [incoming]
[incoming]
exten => s,1,Answer()
exten => s,2,Background(welcome-msg)

exten => 1,1,Dial(SIP/phone1) ; they pushed 1 so transfer them to sip phone1
exten => 2,1,Goto(dial-out,12223334444,1) ; they pushed two which has to transfer them to 1-222-333-4444

[dial-out]
exten => _1NXXNXXXXXX,1,Dial(SIP/provider/${EXTEN}) ; 11 digit numbers go to sip provider.

in the above example, a caller pressing 2 needs to be transferred to an outgoing number. This example does it w/out exposing outgoing lines to incoming calls. Remember, Goto()'d extens will match patterns too.

hope that sort of answers…

Let me try and restate my issue simply.

The issue is that when I create a sip device in the sip.conf file and specifiy the context= directive when a call come in from this device it doesn’t use this context it uses the context specified by context= in the [general] section and if that is not specifed it uses the [default] context even if this has not been specified.

What I am wondering is if I am doing/assuming something wrong in how I am trying to use the context= in the individual sip device.

The documentation indicates that it should work this way but if you review the configs provided and the system debugs you can see it is not.

I have tested this repeatedly with a number of variations and can’t get the incoming call on a sip device to go to the context specified by context= in the device definition.

ahh. the problem then is that for whatever reason it is not matching the entry you provided, and is instead being put in as a guest. try turning off guest access (allowguest=no as i recall, coudl be wrong on that) and chances are it won’t work at all.

Then check the debugs for more info…