Only the s extension works (DID match got 404 error)

Hi, I am play around my dialplan and couldn’t figure out this problem.

First, here is my sip.conf:

[code][general]
context=default

[DigiVoice7777]
username=6042887777
type=friend
secret=passwd
insecure=very
canreinvite=no
host=sip.myvsp.com
fromuser=6042887777
context=from-sip[/code]

Now in extensions.conf

[code][default]
include => internal
include => out-pstn

[from-sip]
exten => 6042887777,1,NoOp(Incoming call from # ${CALLERID(num)})
exten => 6042887777,n,Answer()
exten => 6042887777,n,Goto(do something else)
exten => 6042887777,n,Hangup()

exten => s,1,NoOp(Incoming call from # ${CALLERID(num)})
exten => s,n,Answer()
exten => s,n,Hangup()
[/code]

When try to call 6042887777, the s extension allway pick up the call. If I disable the s extension then the call seems never reached to my Asterisk server. So I tried sip debug and it shows the INVITE but got “404 Not Found” :cry:

Could some one please take a look at my code and point out where I did wrong? Thanks.

I use Asterisk 1.4.11 and here is the full SIP debug log:

[code]S01060008c7a2c772CLI> sip set debug
SIP Debugging enabled>
S01060008c7a2c772
CLI> sip set debug off
<— SIP read from 209.17.160.129:5060 —>
INVITE sip:s@24.87.155.77 SIP/2.0
Via: SIP/2.0/UDP 209.17.160.129:5060;branch=z9hG4bK40fed909;rport
From: “ATCOM KINOWAY” sip:6045556666@209.17.160.129;tag=as013f10ab
To: sip:s@24.87.155.77
Contact: sip:6045556666@209.17.160.129
Call-ID: 71a9227e3e08d5966a6a886e54da2d6f@209.17.160.129
CSeq: 102 INVITE
User-Agent: DV VOIP
Date: Thu, 13 Sep 2007 18:43:50 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY
Content-Type: application/sdp
Content-Length: 291

v=0
o=root 4857 4857 IN IP4 209.17.160.129
s=session
c=IN IP4 209.17.160.129
t=0 0
m=audio 13656 RTP/AVP 0 18 3 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:18 G729/8000
a=rtpmap:3 GSM/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -

<------------->
— (12 headers 13 lines) —
Sending to 209.17.160.129 : 5060 (NAT)
Using INVITE request as basis request - 71a9227e3e08d5966a6a886e54da2d6f@209.17.160.129
Found peer 'DigiVoice7777’
Found RTP audio format 0ip set debug off
Found RTP audio format 18
Found RTP audio format 3
Found RTP audio format 8
Found RTP audio format 101
Peer audio RTP is at port 209.17.160.129:13656
Found description format PCMU for ID 0
Found description format G729 for ID 18
Found description format GSM for ID 3
Found description format PCMA for ID 8
Found description format telephone-event for ID 101
Capabilities: us - 0x8000e (gsm|ulaw|alaw|h263), peer - audio=0x10e (gsm|ulaw|alaw|g729)/video=0x0 (nothing), combined - 0xe (gsm|ulaw|alaw)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event), peer - 0x1 (telephone-event), combined - 0x1 (telephone-event)
Peer audio RTP is at port 209.17.160.129:13656
Looking for s in from-sip (domain 24.87.155.77)

<— Reliably Transmitting (no NAT) to 209.17.160.129:5060 —>
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 209.17.160.129:5060;branch=z9hG4bK40fed909;received=209.17.160.129;rport=5060
From: “ATCOM KINOWAY” sip:6045556666@209.17.160.129;tag=as013f10ab
To: sip:s@24.87.155.77;tag=as701ad3a7
Call-ID: 71a9227e3e08d5966a6a886e54da2d6f@209.17.160.129
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Content-Length: 0

<------------>
Scheduling destruction of SIP dialog ‘71a9227e3e08d5966a6a886e54da2d6f@209.17.160.129’ in 32000 ms (Method: INVITE)
S01060008c7a2c772*CLI> sip set debug off
<— SIP read from 209.17.160.129:5060 —>
CANCEL sip:s@24.87.155.77 SIP/2.0
Via: SIP/2.0/UDP 209.17.160.129:5060;branch=z9hG4bK40fed909;rport
From: “ATCOM KINOWAY” sip:6045556666@209.17.160.129;tag=as013f10ab
To: sip:s@24.87.155.77
Contact: sip:6045556666@209.17.160.129
Call-ID: 71a9227e3e08d5966a6a886e54da2d6f@209.17.160.129
CSeq: 102 CANCEL
User-Agent: DV VOIP
Content-Length: 0

<------------->
— (9 headers 0 lines) —
Sending to 209.17.160.129 : 5060 (NAT)
Scheduling destruction of SIP dialog ‘71a9227e3e08d5966a6a886e54da2d6f@209.17.160.129’ in 32000 ms (Method: CANCEL)

<— Reliably Transmitting (NAT) to 209.17.160.129:5060 —>
SIP/2.0 487 Request Terminated
Via: SIP/2.0/UDP 209.17.160.129:5060;branch=z9hG4bK40fed909;received=209.17.160.129;rport=5060
From: “ATCOM KINOWAY” sip:6045556666@209.17.160.129;tag=as013f10ab
To: sip:s@24.87.155.77;tag=as701ad3a7
Call-ID: 71a9227e3e08d5966a6a886e54da2d6f@209.17.160.129
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Content-Length: 0

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

<— Transmitting (NAT) to 209.17.160.129:5060 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 209.17.160.129:5060;branch=z9hG4bK40fed909;received=209.17.160.129;rport=5060
From: “ATCOM KINOWAY” sip:6045556666@209.17.160.129;tag=as013f10ab
To: sip:s@24.87.155.77;tag=as701ad3a7
Call-ID: 71a9227e3e08d5966a6a886e54da2d6f@209.17.160.129
CSeq: 102 CANCEL
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Contact: sip:s@24.87.155.77
Content-Length: 0

<------------>
S01060008c7a2c772*CLI> sip set debug off
<— SIP read from 209.17.160.129:5060 —>
ACK sip:s@24.87.155.77 SIP/2.0
Via: SIP/2.0/UDP 209.17.160.129:5060;branch=z9hG4bK40fed909;rport
From: “ATCOM KINOWAY” sip:6045556666@209.17.160.129;tag=as013f10ab
To: sip:s@24.87.155.77;tag=as701ad3a7
Contact: sip:6045556666@209.17.160.129
Call-ID: 71a9227e3e08d5966a6a886e54da2d6f@209.17.160.129
CSeq: 102 ACK
User-Agent: DV VOIP
Content-Length: 0

<------------->
— (9 headers 0 lines) —
Retransmitting #1 (NAT) to 209.17.160.129:5060:
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 209.17.160.129:5060;branch=z9hG4bK40fed909;received=209.17.160.129;rport=5060
From: “ATCOM KINOWAY” sip:6045556666@209.17.160.129;tag=as013f10ab
To: sip:s@24.87.155.77;tag=as701ad3a7
Call-ID: 71a9227e3e08d5966a6a886e54da2d6f@209.17.160.129
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Content-Length: 0


S01060008c7a2c772*CLI> sip set debug off
SIP Debugging Disabled
[/code]

the ‘s’ catchs any calls coming into that context

the dialplan doesnt know what call your coming from.
if your wanting it to do certain things with certain phone numbers coming in you could maybe try this?
[from-sip]
exten => ${CALLERID(6042887777)},1,NoOp(Incoming call from # ${CALLERID(num)})
exten => ${CALLERID(6042887777)},n,Answer()
exten => ${CALLERID(6042887777)},n,Goto(do something else)
exten => ${CALLERID(6042887777)},n,Hangup()

it should be something like that i have never done it. let me know if you figure it out id like to do this on mine that can be reaaaaaly handy for DISA and stuff to come into a different IVR for OWNERS or what not from thier cellphones…
if you dont figure it out ill figure it out tonite after work and let ya know.

ps…why do i keep seeing people use NoOP? Why not just start with Answer() ??

I forget to mention that I want when dialer calls to the 642887777 number, * will do something special.

I also have other DID numbers and I want sent all the other calls to IVR catched by the s extension.

i think i might have read your first message wrong now…
is that phone number an anlalog line coming into your asterisk?

you could just make a new context for it in extensions.conf, and in your zapata.conf for that channel set it to that new context.

then just use your ‘s’ extensions and it will dump the call into that new context into the ‘s’ extesion and you can do whatever you feel like after that.

Just leave all your other analog lines in the old context in extensions.conf…

i think that is what your wanting ?

Thank you, CustomGT.

The context doesn’t work. Samething as before.

So I guess I’ll wait till tonight? :wink:

PS. I use NoOP just to help me to look at the CLI so I know the calls have been handlesd by the correct context.

[quote=“CustomGT”]the ‘s’ catchs any calls coming into that context

the dialplan doesnt know what call your coming from.
if your wanting it to do certain things with certain phone numbers coming in you could maybe try this?
[from-sip]
exten => ${CALLERID(6042887777)},1,NoOp(Incoming call from # ${CALLERID(num)})
exten => ${CALLERID(6042887777)},n,Answer()
exten => ${CALLERID(6042887777)},n,Goto(do something else)
exten => ${CALLERID(6042887777)},n,Hangup()

it should be something like that i have never done it. let me know if you figure it out id like to do this on mine that can be reaaaaaly handy for DISA and stuff to come into a different IVR for OWNERS or what not from thier cellphones…
if you dont figure it out ill figure it out tonite after work and let ya know.

ps…why do i keep seeing people use NoOP? Why not just start with Answer() ??[/quote]

No, It is SIP account and my Asterisk is pure SIP, no Zap, no IAX.

oh you have a sip provider…i havent dealt with that.
If all of your lines are from a sip provider can you set them to come into different contexts in extensions.conf or is that not a feature?

if it is you can just set that one line to go into a sepereate context in extensions.conf and let the rest of the sip lines dump into another context in extensions.conf

Change the context name in your sip.conf file from [DigiVoice7777] to [6042887777].

Be sure that the login credentials used by the sip client are using 6042887777 as a login id.

Add include => from-sip in your extensions.conf [default] context.

Restart.

You should be able to call the sip client at 6042887777 phone number now.

Hi, dufus,

I followed your instructions and it is still the same.

now from CLI:

S01060008c7a2c772*CLI> sip show peers Name/username Host Dyn Nat ACL Port Status 2008/2008 (Unspecified) D N 0 UNKNOWN 2007/2007 (Unspecified) D N 0 UNKNOWN 2006/2006 (Unspecified) D N 0 UNKNOWN 6042887777/6042887777 209.17.160.129 5060 Unmonitored 4 sip peers [Monitored: 0 online, 3 offline Unmonitored: 1 online, 0 offline] S01060008c7a2c772*CLI> sip show registry Host Username Refresh State Reg.Time sip.myvsp.ca:5060 6042887777 105 Registered Thu, 13 Sep 2007 12:37:06

oh you have a sip provider…i havent dealt with that.
If all of your lines are from a sip provider can you set them to come into different contexts in extensions.conf or is that not a feature?

if it is you can just set that one line to go into a sepereate context in extensions.conf and let the rest of the sip lines dump into another context in extensions.conf[/quote]

give 6042887777 in sip.conf:
context=from-sip-6042887777

in extensions.conf make a new context
[from-sip-6042887777]
exten => s,1,blah blah
etc etc etc

and leave your other stuff alone. since you said you were wanting to do some custom things that you have not mentioned in here it might be nice to have it in its own context to keep it tidy

CustomGT, that works. Thank you very much.

But I still don’t understand why doing a DID match doesn’t work. Like in my first post, in the [from-sip] context, * should try to match the dialed DID first, right? So it looks like I am limited to use the ‘s’ option only. :cry:

Another thought, do you think I should make two seperate contexts for the same account, as peer and user, instead of just use friend.

It’s really not the ‘s’ option. It’s the context.

Contexts are a way to segment the services and connections of an Asterisk server.

In your system, you had your sip device (in this case, a client with a phone number of 6042887777) as part of a context called from-sip (Well, originally. CustomGT had you change that to from-sip-6042887777.)

Calls originate at a particular channel, and inherit the “context” assigned to that channel. When Asterisk checks the extensions.conf file to see what to do with that call, it starts in the default context. If the default context doesn’t have instructions, it must have an include statement to allow the call to check other contexts for further instructions.

If you start in another context, Asterisk checks for routing instructions in that context.

The order that they are listed is somewhat important. If determines which context is checked first, second, third and so forth. If you want calls that seek outside trunks to try your SIP provider first, and then try a local analog line (because the SIP calls are cheaper than analog) you’d might list it like this:

include => sip-provider
include => local-line

Now, you COULD have simply put all of the lines you had for the 6042887777 sip client into the default context. But, as CustomGT said, it makes things a bit messy when you just pile everything into default. Segmenting things with contexts allows you to have more control.

However, when you design your extensions.conf file to use that control, you need to take the extra steps necessary to tie everything together, with consideration for the order you want events to happen.

In your case, if you had simply added the incude => from-sip to the bottom of your list of include statements like this:

include => internal
include => out-pstn
include => from-sip

The incoming calls will start the services in the first context that they find has instructions that they can execute. If there is an ‘s’ instruction in the internal context, it’ll always choose that first, and never make it to the from-sip context to dial your station.

You have to think about the events you’d like to have happen. (Like ringing a station, and starting an IVR application.) Build those events in individual contexts, and then put those events into the system in the order you’d like them to occur.

I would have done this…

include => from-sip
include => internal
include => out-pstn

…if I wanted to have a sip client that may or may not be registered, and I wanted that sip client to be the first thing to ring for incoming calls if it was registered. If that sip client wasn’t registered, I’d have the system try the internal context where it would find my IVR that would allow callers to leave me a message, or find other information in an automated way.

so if his sip line context is:
context=from-sip

and his extensions.conf:
[default]
include => internal
include => out-pstn

[from-sip]
exten => 6042887777,1,NoOp(Incoming call from # ${CALLERID(num)})
exten => 6042887777,n,Answer()
exten => 6042887777,n,Goto(do something else)
exten => 6042887777,n,Hangup()

exten => s,1,NoOp(Incoming call from # ${CALLERID(num)})
exten => s,n,Answer()
exten => s,n,Hangup()

Your saying asterisk will look in [default] for instructions before [from-sip] for that sip line?
If that is true Im glad I know that now, I can see running into some headaches by not knowing that…

Not exactly.

Asterisk will always check the current context first. If the context of the incoming call is from-sip, it will check from-sip first.

If it can’t determine the context of the call, (or one isn’t listed for the resource) it moves on to the default context.

It will check any other contexts that are listed as include => statements in the order that they are listed. It will start checking the current context, and if it can’t determine the current context, it will move on to the default, and check the include => contexts there.

Either way, you have to bridge the calls you make to the services and resources of other contexts by using include statements. Your preference for which happens first is determined by the order they are listed.