DID not following designated route **RESOLVED**

I have a MyPhoneCompany trunk set up as a Sip trunk.
I have a MyPhoneCompany inbound route set up to detect the DID, and a any/any route set up.

When calls come into the MyphoneCo did, they seem to follow the any/any route, as apposed to the MPC inbound route.

Can someone point me to a direction to look in for the problem here?

Thanks
Sam

If I look in the call log report, it shows the did as the sip / channel so it does know where it came from it just dont seem to be following the route.

hmmmmmm

Confused
Sam

If you do an:
$ asterisk -r
with verbose debugging enabled
and watch your call come through, you will see the details

You can compare those to your route and figure out what you’re missing.

Or you can post the details and other people can help you.

I take it that I do this in FreePBX , admin, tools, asterisk cli? and I watch the output under Asterisk logfiles, where i get the last 2000 lines?

I just wanted to make sure that i understood what you were telling me to do to make sure I got the correct info.

Many Thanks
Sam

no,
ssh into your box, type ‘asterisk -rvvvvv’, then watch it in real time there. The log files are much harder to follow.

Thanks for the info, I completely forgot about using ssh to log in.

i did so, and here is the results. I dont think there is a security risk on posting this.

Results =

Verbosity was 3 and is now 5

-- Executing [[email protected]:1] Set("SIP/6066204338-09011b60", "__FROM_DID=s")                                                                              in new stack
-- Executing [[email protected]:2] Gosub("SIP/6066204338-09011b60", "app-blacklis                                                                             t-check|s|1") in new stack
-- Executing [[email protected]:1] LookupBlacklist("SIP/6066204338-09011                                                                             b60", "") in new stack
-- Executing [[email protected]:2] GotoIf("SIP/6066204338-09011b60", "0?                                                                             blacklisted") in new stack
-- Executing [[email protected]:3] Return("SIP/6066204338-09011b60", "")                                                                              in new stack
-- Executing [[email protected]:3] GotoIf("SIP/6066204338-09011b60", "1 ?cidok")                                                                              in new stack
-- Goto (from-trunk,s,5)
-- Executing [[email protected]:5] NoOp("SIP/6066204338-09011b60", "CallerID is "                                                                             Bowman Jerry   " <+16065283607>") in new stack
-- Executing [[email protected]:6] Set("SIP/6066204338-09011b60", "_RGPREFIX=Any-                                                                             ") in new stack
-- Executing [[email protected]:7] Set("SIP/6066204338-09011b60", "CALLERID(name)                                                                             =Any-Bowman Jerry   ") in new stack
-- Executing [[email protected]:8] Goto("SIP/6066204338-09011b60", "ivr-2|s|1") i                                                                             n new stack
-- Goto (ivr-2,s,1)
-- Executing [[email protected]:1] Set("SIP/6066204338-09011b60", "LOOPCOUNT=0") in ne                                                                             w stack
-- Executing [[email protected]:2] Set("SIP/6066204338-09011b60", "__DIR-CONTEXT=defau                                                                             lt") in new stack
-- Executing [[email protected]:3] Set("SIP/6066204338-09011b60", "_IVR_CONTEXT_ivr-2=                                                                             ") in new stack
-- Executing [[email protected]:4] Set("SIP/6066204338-09011b60", "_IVR_CONTEXT=ivr-2"                                                                             ) in new stack
-- Executing [[email protected]:5] GotoIf("SIP/6066204338-09011b60", "0?begin") in new                                                                              stack
-- Executing [[email protected]:6] Answer("SIP/6066204338-09011b60", "") in new stack
-- Executing [[email protected]:7] Wait("SIP/6066204338-09011b60", "1") in new stack
-- Executing [[email protected]:8] Set("SIP/6066204338-09011b60", "TIMEOUT(digit)=3")                                                                              in new stack
-- Digit timeout set to 3
-- Executing [[email protected]:9] Set("SIP/6066204338-09011b60", "TIMEOUT(response)=1                                                                             0") in new stack
-- Response timeout set to 10
-- Executing [[email protected]:10] BackGround("SIP/6066204338-09011b60", "custom/swit                                                                             chboard1") in new stack
-- <SIP/6066204338-09011b60> Playing 'custom/switchboard1' (language 'en')

== Spawn extension (ivr-2, s, 10) exited non-zero on ‘SIP/6066204338-09011b60’
– Executing [[email protected]:1] Hangup(“SIP/6066204338-09011b60”, “”) in new stack
== Spawn extension (ivr-2, h, 1) exited non-zero on 'SIP/6066204338-09011b60’
asterisk*CLI>


I have researched, and went by this article.

http://freepbx.org/support/documentation/howtos/how-to-get-the-did-of-a-sip-trunk

and tried the ideals contained there, including this.

[custom-get-did-from-sip]
exten => _.,1,Noop(Fixing DID using information from SIP TO header)
exten => _.,n,Set(pseudodid=${CUT(CUT(SIP_HEADER(To),@,1),:,2)})
exten => _.,n,Set(pseudodid=${IF($["${pseudodid}"=“s”]?6066204338:${pseudodid})})
exten => _.,n,Goto(from-trunk,${pseudodid},1)

which still resulted in the call falling to the Any/Any route.

Now I can hard code it in with this.

[custom-stupid-provider]
exten => _.,1,Noop(Fixing DID to 6066204338)
exten => _.,n,Goto(from-trunk,6066204338,1)

but would like to get it to actually take care of it with detection as apposed to hardcode.

Any further ideals what I am missing or miss understanding?

also, the incomming coller id on this route shows up as +1 in front of the 10 digit phone numbers, is there a way to strip that down ?

Thanks
Sam

If you have a registration string with your provider try appending your DID to it, ie;

yourAccount:[email protected]/DID

I don’t think your provider is sending the DID information correctly. Your log shows From_DID=s. Appending your DID to the registration string may resolve it.

Hey John,

That worked great adding the did number to the end of the reg string. that is the first time i have heard that one and it worked like a charm on getting the did to follow the proper route.

Thank you very much

Now on to last issue of getting Caller id to drop that +1 from the beginning of the numbers.

Thanks again
Sam

You can do that by adding a few lines of code in extensions_custom.conf

[from-pstn-custom]

exten => _X.,1,if(${CALLERID(number):0:1}=1?next:leave)
exten => _X.,n(next),Set(CALLERID(number)=${CALLERID(number):1})
exten => _x.,n(leave), NOOP()

; end of from-pstn-custom

Be careful, this will strip the 1 from any number that begins with 1, including country codes that begin with 1. I don’t think that there are any and I don’t think any US area codes or exchanges begin with 1, so this should be safe.

This is untested code, so you may need to tinker a little to get this working.

Hey John,

When I add the lines to my extensions_custom.conf. do I need to add a context line in the trunk anywhere? or just add this to extensions_custom.conf and let it be?

if i am guessing, i need to add something in the trunk to get it to read this, something like the Context= line.

right now I have Context=from-trunk
do i need to add Context=from-pstn-custom
?

Thanks for any help

Regards
Sam

Sam,

If I am not mistaken, the “from-trunk” context includes the “from-pstn” context which includes the “from-pstn-custom” context.

It should work by just adding the “from-pstn-custom” context to extensions_custom.conf. Like I said earlier, I didn’t test this, so you may have to tinker with the script a bit.