Unable to internal routing (to ext) based upon called ID by customer

Dear all my issue is very simple but I am unable to fix. I have a callcentric account and our offices have USA/UK/AUS numbers for customers i.e. people in USA call on our USA number, people in UK on our UK number etc. and all these calls terminate via callcentric to our office.
Previously within callcentric we had few DIDs setup so that if call comes from
US number it would go to ext 10, 11, 12
UK would go to ext 20, 21, 22
AUS would go to ext 30, 31, 32
or in simple words, routing based upon Called ID (my USA, UK, AUS number for customers)

Now, as you know cc gives your one number 1777XXXXXXX
So how I setup freepbx for same as I can put this 1777XXXXX number in one trunk.
I know some other people have also raised this issue but one problem that I am facing is that I noticed is that the caller ID would always be my test mobile number and hence I could not route calls based upon caller ID (which is what I have to achieve). My freepbx is unable to forward the callcentric DID, it’s always forwarding my test mobile. And I can forward DID of callcentric only for one.

I have freepbx latest version with asterisk 13

Routing based on Caller ID isn’t hard to do, but I’m not sure you can use Caller ID Wildcards on an incoming route.

Just so we’re clear - you do mean Caller ID (CID) and not Direct In Dial (DID), right?

You can specify inbound routes without a DID and use a CID instead. If the inbound route allows for wildcards, you should be fine. If not, you’re probably going to need to write a custom context for your inbound routes that splits out your incoming calls to your ring groups.

A discussion you should follow. Sounds like a similar (programmatically) solution.

I am actually confused about CID and DID (in the context of callcentric since it only allows only number to be forwarded so obviously then the only decision making criteria for us is to compare what number the customer has dialed. If he has dialed our X number then call should go to agent 1,2,3 and if he has dialed our Y number call may go to 5,6,7 extension.

Where i should make this comparison ?
In inbound route or trunk or where?

Let me try to explain again:

This CID – DID thing is so confusing but let me explain as simpler as possible :

E.g. my mobile number is 1122334455
In my call centric account I have DID setup as follow :
111111111 >> 1777XXXXXXX @in.callcentric.com
As per above DID whoever (in this case my test number 1122334455) calls 111111111 the call will be forwarded to myfreepbx extension

Well the call DOES go to my freepbx , on whatever extension I am setting (let’s say 148,149,150 using ring group)

This whole setup is for USA and it works fine. The problem is when I try to add another country.

How do I achieve this?
I have created 3 extensions for UK (let’s say 200/201), now should I only set up inbound route or should I add another extension?
I have tried both but the problem is when I set up for UK the incoming call instead of going to 201/202 goes to USA extensions (148/149/150)

Firstly I am confused at what configurations I need to setup and then what exactly I should put in there.

Keep in mind that i have only one callcentric number.

correction :
Should i only add inbound route or another TRUNK (or only trunk ) ?

Trunks are how you connect to the PSTN (regardless of how you connect), so you should only have one trunk per destination server or connection (IP address, POTS line, PRI, etc.). Of course, that’s a super simple way to think about and there are some subtle things about that which we’ll cover in future installments. Basically, when your Internet Telephone Service Provider (ITSP) sends you a call, regardless of anything else, it comes into a trunk.

Trunks cycle through your inbound routes, so all of your trunks talk to all of your inbound routes. When a new call comes in, it checks the number that the far end called (your DID) on the inbound route. At the same time, the trunk passes the Caller ID (CID) of the person that called. That’s important - read it again if it isn’t crystal clear.

Give that, how does the system know which Inbound Route to use? There are four cases (with one twist) that we need to consider (in this order):

  1. The Inbound Route has a DID set and a CID set. In this case, both pieces of information are compared against what the Trunk passed to the IR and if they match, this IR is used.
  2. The Inbound Route has a DID set but the CID is empty. If the number that got called matches the DID, this path is chosen, regardless of the CID used. This is good for “general purpose” numbers that aren’t for a specific customer.
  3. The Inbound Route as a CID set but the DID is empty. At this point, the DID didn’t match any of the ones you entered, so the Caller ID is used to select the Inbound Route. Not used very often, but can be useful.
  4. The Inbound Route has both the CID and DID blank. This is called an “Any/Any” route. Anything that didn’t match something above drops into this route. This, by the way, is probably the most common Inbound Route (all numbers get dropped into an IVR, for example).

So, your CallCentric call is going to your machine. The DID should be what the original caller called, or at least should be the “common” DID for that number. In your example, that is either going to be ‘11111111’ or ‘1777xxxxxxx’. The logs can tell you.

When you call from your cell phone, the CID is going to be the number of your cell phone.

So, the number the person calls is the DID. The number they called from is the CID.

Now, on to your problem. First, if you don’t already have one, set up an “Any/Any” Inbound Route to catch all of your incoming calls. Next, set an Inbound Route (just add a new one) with the DID set to blank and Caller ID set to your cell phone. For this step, you might have to look at the Asterisk logs to find out what CallCentric is sending for your cell phone CID Number. There are lots of variations, including “+” on the front, or “0” followed by your country code and number, of ‘whatever’. The log will tell you what you need to match.

This way, you can set the destination to your IVR (or an announcement, or something specific that you will recognize) and test away on each.

Next try replacing the last digit of your cell phone number with an “X”. Call again. Your call should be forwarded to the same place it was before (instead of the Any/Any route). If you can get to the point where you are matching your cell phone number with most of it replaced by ‘X’, they you can proceed to set up inbound routes based on Area Code or Country Code.

If the wildcards don’t work (and I can’t test this right now), you might need to resort to adding a custom inbound context. Basically, you set a new context in “extensions_custom.conf” that uses the substring function on the “Caller ID Number” variable. There are lots of ways to proceed from there, including changing the apparent DID or adding a selector on the CID.

In extensions.conf, there is something called “something.E164.something” that can be used as a template for writing this code. You can also search the archive of this group and try one of the solutions people have posted in the past.

There are (at least) two ways to handle DID-based routing with Callcentric.

  1. Set DID Forwarding for all your DIDs to Default. Assuming no Call Treatments, all incoming calls will have your 1777XXXXXX Callcentric number in the SIP URI, but the To: header will contain the DID number. In FreePBX, set the context for your Callcentric trunk to from-pstn-toheader ; your Inbound Route can then match the DID, e.g. 16465471111 and route accordingly.

  2. In Callcentric, set up an Extension for each DID. Set DID Forwarding to route each DID to the corresponding extension. Incoming calls will then have a unique URI, e.g. 1777XXXXXXX101, 1777XXXXXXX102, etc. Put those 1777 numbers including the extension in your Inbound Routes.

1 Like

Dear all thanks alot for all your support and time and apologies for a late reply. I was however trying my best to get this working and here are my findings.

I am able to call outbound from both of my trunks (say A and B ) for both destinations USA and UK

However the inbound call issue is still there. Now the problem is wrong DID is being show in call logs and CDR records e.g

My trunk A has an Inbound route A which has a DID for USA
My trunk B has an Inbound route B which has a DID for UK

The inbound calls are forwarding random DID to my asterisk (and because my internal routing is based upon this DID the call instead of going to extension X goes to extension Y ) . I noticed that whenever a right DID is forwarded the call goes to the right extension so it means my internal routing is fine.

Dear Stewart1, i have already tried option 1 you mentioned but it didnt work.
Option 2 i could not understand because withing callcentric i can forward calls to only those extensions which exist in callcentric EXTENSIONS list. I dont see how i mention my freepbx extensions in callcentric

What goes wrong? At the Asterisk command prompt, do
sip set debug on
or
pjsip set logger on
and make test calls to your DIDs.
You should see the incoming INVITEs in the Asterisk log. Confirm that the To header contains the called number. Confirm that the from-pstn-toheader code is being executed and that it jumps to from-pstn at the correct ‘extension’ (which should be the DID number).

For example, you have DID 12122222222 which you route to Callcentric extension 101. You also have DID 442073333333 routed to CC extension 102. Let’s say your CC account is 17774444444. Have FreePBX register to both 17774444444101 and 17774444444102. Then, calls to the New York number should have 17774444444101 in the SIP URI, while calls to the London number will have 1777444444102. So, your Inbound Route for New York will specify 17774444444101 for the DID and the one for London will use 17774444444102.

Dear Stewart i have attached a screenshot of all my settings. Please have a look at them.

Black marking is for USA and orange is for UK.

At the top is the callcentric gui showing the two DIDs i have set up.

Please note that the destination extensions (148 for USA and 149 for UK ) are temporary , i will later replace them with a ring group but right now for simplicity i am using just single extension.

Dear friends please find below a log that i collected after enable pjsip logger.

Note that i called my USA number in this case (which is 16xxxxxxxx1 ) so it should end up on my 148 extension but as soon as this call enters my freepbx system its showing the UK DID ( 44xxxxx ) and hence terminating at my 149 extension. which is WRONG

When i check the CDR it shows my DID as 44xxxxxxx so basically there is it something wrong with call centric which is sending wrong DID ?

I have highlighted few things. Please let me know if they are of any significance. Please read below logs
Thanks to you all in advance.

== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
> 0x7f803c598780 – Strict RTP learning after remote address set to: 204.11.192.160:52132
– Executing [44xxxxxxxxx4@from-sip-external:1] NoOp(“SIP/callcentric.com-00000018”, “Received incoming SIP connection from unknown peer to 44xxxxxxxxx4”) in new stack
– Executing [44xxxxxxxxx4@from-sip-external:2] Set(“SIP/callcentric.com-00000018”, “DID=44xxxxxxxxx4”) in new stack
– Executing [44xxxxxxxxx4@from-sip-external:3] Goto(“SIP/callcentric.com-00000018”, “s,1”) in new stack
– Goto (from-sip-external,s,1)
– Executing [s@from-sip-external:1] GotoIf(“SIP/callcentric.com-00000018”, “1?setlanguage:checkanon”) in new stack
– Goto (from-sip-external,s,2)
– Executing [s@from-sip-external:2] Set(“SIP/callcentric.com-00000018”, “CHANNEL(language)=en”) in new stack
– Executing [s@from-sip-external:3] GotoIf(“SIP/callcentric.com-00000018”, “0?noanonymous”) in new stack
– Executing [s@from-sip-external:4] Goto(“SIP/callcentric.com-00000018”, “from-trunk,44xxxxxxxxx4,1”) in new stack
– Goto (from-trunk,44xxxxxxxxx4,1)
– Executing [44xxxxxxxxx4@from-trunk:1] Set(“SIP/callcentric.com-00000018”, “__DIRECTION=INBOUND”) in new stack
– Executing [44xxxxxxxxx4@from-trunk:2] Gosub(“SIP/callcentric.com-00000018”, “sub-record-check,s,1(in,44xxxxxxxxx4,no)”) in new stack
– Executing [s@sub-record-check:1] GotoIf(“SIP/callcentric.com-00000018”, “0?initialized”) in new stack
– Executing [s@sub-record-check:2] Set(“SIP/callcentric.com-00000018”, “__REC_STATUS=INITIALIZED”) in new stack
– Executing [s@sub-record-check:3] Set(“SIP/callcentric.com-00000018”, “NOW=1527090825”) in new stack
– Executing [s@sub-record-check:4] Set(“SIP/callcentric.com-00000018”, “__DAY=23”) in new stack
– Executing [s@sub-record-check:5] Set(“SIP/callcentric.com-00000018”, “__MONTH=05”) in new stack
– Executing [s@sub-record-check:6] Set(“SIP/callcentric.com-00000018”, “__YEAR=2018”) in new stack
– Executing [s@sub-record-check:7] Set(“SIP/callcentric.com-00000018”, “__TIMESTR=20180523-155345”) in new stack
– Executing [s@sub-record-check:8] Set(“SIP/callcentric.com-00000018”, “__FROMEXTEN=unknown”) in new stack
– Executing [s@sub-record-check:9] Set(“SIP/callcentric.com-00000018”, “__MON_FMT=wav”) in new stack
– Executing [s@sub-record-check:10] NoOp(“SIP/callcentric.com-00000018”, “Recordings initialized”) in new stack
– Executing [s@sub-record-check:11] ExecIf(“SIP/callcentric.com-00000018”, “0?Set(ARG3=dontcare)”) in new stack
– Executing [s@sub-record-check:12] Set(“SIP/callcentric.com-00000018”, “REC_POLICY_MODE_SAVE=”) in new stack
– Executing [s@sub-record-check:13] ExecIf(“SIP/callcentric.com-00000018”, “0?Set(REC_STATUS=NO)”) in new stack
– Executing [s@sub-record-check:14] GotoIf(“SIP/callcentric.com-00000018”, “2?checkaction”) in new stack
– Goto (sub-record-check,s,17)
– Executing [s@sub-record-check:17] GotoIf(“SIP/callcentric.com-00000018”, “1?sub-record-check,in,1”) in new stack
– Goto (sub-record-check,in,1)
– Executing [in@sub-record-check:1] NoOp(“SIP/callcentric.com-00000018”, “Inbound Recording Check to 44xxxxxxxxx4”) in new stack
– Executing [in@sub-record-check:2] Set(“SIP/callcentric.com-00000018”, “FROMEXTEN=unknown”) in new stack
– Executing [in@sub-record-check:3] ExecIf(“SIP/callcentric.com-00000018”, “14?Set(FROMEXTEN=+192xxxxxxxxxx)”) in new stack
– Executing [in@sub-record-check:4] Gosub(“SIP/callcentric.com-00000018”, “recordcheck,1(no,in,44xxxxxxxxx4)”) in new stack
– Executing [recordcheck@sub-record-check:1] NoOp(“SIP/callcentric.com-00000018”, “Starting recording check against no”) in new stack
– Executing [recordcheck@sub-record-check:2] Goto(“SIP/callcentric.com-00000018”, “no”) in new stack
– Goto (sub-record-check,recordcheck,12)
– Executing [recordcheck@sub-record-check:12] Set(“SIP/callcentric.com-00000018”, “__REC_POLICY_MODE=NO”) in new stack
– Executing [recordcheck@sub-record-check:13] Return(“SIP/callcentric.com-00000018”, “”) in new stack
– Executing [in@sub-record-check:5] Return(“SIP/callcentric.com-00000018”, “”) in new stack
– Executing [44xxxxxxxxx4@from-trunk:3] Gosub(“SIP/callcentric.com-00000018”, “app-blacklist-check,s,1()”) in new stack
– Executing [s@app-blacklist-check:1] GotoIf(“SIP/callcentric.com-00000018”, “0?blacklisted”) in new stack
– Executing [s@app-blacklist-check:2] Set(“SIP/callcentric.com-00000018”, “CALLED_BLACKLIST=1”) in new stack
– Executing [s@app-blacklist-check:3] Return(“SIP/callcentric.com-00000018”, “”) in new stack
– Executing [44xxxxxxxxx4@from-trunk:4] Set(“SIP/callcentric.com-00000018”, “__FROM_DID=44xxxxxxxxx4”) in new stack
– Executing [44xxxxxxxxx4@from-trunk:5] Set(“SIP/callcentric.com-00000018”, “CDR(did)=44xxxxxxxxx4”) in new stack
– Executing [44xxxxxxxxx4@from-trunk:6] ExecIf(“SIP/callcentric.com-00000018”, “0 ?Set(CALLERID(name)=+192xxxxxxxxxx)”) in new stack
– Executing [44xxxxxxxxx4@from-trunk:7] Set(“SIP/callcentric.com-00000018”, “__MOHCLASS=”) in new stack
– Executing [44xxxxxxxxx4@from-trunk:8] Ringing(“SIP/callcentric.com-00000018”, “”) in new stack
– Executing [44xxxxxxxxx4@from-trunk:9] Set(“SIP/callcentric.com-00000018”, “__RINGINGSENT=TRUE”) in new stack
– Executing [44xxxxxxxxx4@from-trunk:10] Set(“SIP/callcentric.com-00000018”, “__REVERSAL_REJECT=FALSE”) in new stack
– Executing [44xxxxxxxxx4@from-trunk:11] GotoIf(“SIP/callcentric.com-00000018”, “1?post-reverse-charge”) in new stack
– Goto (from-trunk,44xxxxxxxxx4,13)
– Executing [44xxxxxxxxx4@from-trunk:13] NoOp(“SIP/callcentric.com-00000018”, “”) in new stack
– Executing [44xxxxxxxxx4@from-trunk:14] Set(“SIP/callcentric.com-00000018”, “__CALLINGNAMEPRES_SV=allowed_not_screened”) in new stack
– Executing [44xxxxxxxxx4@from-trunk:15] Set(“SIP/callcentric.com-00000018”, “__CALLINGNUMPRES_SV=allowed_not_screened”) in new stack
– Executing [44xxxxxxxxx4@from-trunk:16] Set(“SIP/callcentric.com-00000018”, “CALLERID(name-pres)=allowed_not_screened”) in new stack
– Executing [44xxxxxxxxx4@from-trunk:17] Set(“SIP/callcentric.com-00000018”, “CALLERID(num-pres)=allowed_not_screened”) in new stack
– Executing [44xxxxxxxxx4@from-trunk:18] NoOp(“SIP/callcentric.com-00000018”, “CallerID Entry Point”) in new stack
– Executing [44xxxxxxxxx4@from-trunk:19] Set(“SIP/callcentric.com-00000018”, “__CRM_DIRECTION=INBOUND”) in new stack
– Executing [44xxxxxxxxx4@from-trunk:20] Set(“SIP/callcentric.com-00000018”, “__CRM_SOURCE=+192xxxxxxxxxx”) in new stack
– Executing [44xxxxxxxxx4@from-trunk:21] Set(“SIP/callcentric.com-00000018”, “__CRM_LINKEDID=1527090825.41”) in new stack
– Executing [44xxxxxxxxx4@from-trunk:22] ExecIf(“SIP/callcentric.com-00000018”, “1?Set(CHANNEL(hangup_handler_push)=crm-hangup,s,1)”) in new stack
– Executing [44xxxxxxxxx4@from-trunk:23] Goto(“SIP/callcentric.com-00000018”, “from-did-direct,149,1”) in new stack
– Goto (from-did-direct,149,1)
– Executing [149@from-did-direct:1] GotoIf(“SIP/callcentric.com-00000018”, “1?ext-local,149,1:followme-check,149,1”) in new stack
– Goto (ext-local,149,1)
– Executing [149@ext-local:1] Set(“SIP/callcentric.com-00000018”, “__RINGTIMER=15”) in new stack
– Executing [149@ext-local:2] Macro(“SIP/callcentric.com-00000018”, “exten-vm,novm,149,0,0,0”) in new stack
– Executing [s@macro-exten-vm:1] Macro(“SIP/callcentric.com-00000018”, “user-callerid,”) in new stack
– Executing [s@macro-user-callerid:1] Set(“SIP/callcentric.com-00000018”, “TOUCH_MONITOR=1527090825.41”) in new stack
– Executing [s@macro-user-callerid:2] Set(“SIP/callcentric.com-00000018”, “AMPUSER=+192xxxxxxxxxx”) in new stack
– Executing [s@macro-user-callerid:3] GotoIf(“SIP/callcentric.com-00000018”, “0?report”) in new stack
– Executing [s@macro-user-callerid:4] ExecIf(“SIP/callcentric.com-00000018”, “1?Set(REALCALLERIDNUM=+192xxxxxxxxxx)”) in new stack
– Executing [s@macro-user-callerid:5] Set(“SIP/callcentric.com-00000018”, “AMPUSER=”) in new stack
– Executing [s@macro-user-callerid:6] GotoIf(“SIP/callcentric.com-00000018”, “0?limit”) in new stack
– Executing [s@macro-user-callerid:7] Set(“SIP/callcentric.com-00000018”, “AMPUSERCIDNAME=”) in new stack
– Executing [s@macro-user-callerid:8] ExecIf(“SIP/callcentric.com-00000018”, “0?Set(__CIDMASQUERADING=TRUE)”) in new stack
– Executing [s@macro-user-callerid:9] GotoIf(“SIP/callcentric.com-00000018”, “1?report”) in new stack
– Goto (macro-user-callerid,s,16)
– Executing [s@macro-user-callerid:16] NoOp(“SIP/callcentric.com-00000018”, “Macro Depth is 2”) in new stack
– Executing [s@macro-user-callerid:17] GotoIf(“SIP/callcentric.com-00000018”, “1?report2:macroerror”) in new stack
– Goto (macro-user-callerid,s,19)
– Executing [s@macro-user-callerid:19] GotoIf(“SIP/callcentric.com-00000018”, “0?continue”) in new stack
– Executing [s@macro-user-callerid:20] Set(“SIP/callcentric.com-00000018”, “__TTL=64”) in new stack
– Executing [s@macro-user-callerid:21] GotoIf(“SIP/callcentric.com-00000018”, “1?continue”) in new stack
– Goto (macro-user-callerid,s,37)
– Executing [s@macro-user-callerid:37] Set(“SIP/callcentric.com-00000018”, “CALLERID(number)=+192xxxxxxxxxx”) in new stack
– Executing [s@macro-user-callerid:38] Set(“SIP/callcentric.com-00000018”, “CALLERID(name)=+192xxxxxxxxxx”) in new stack
– Executing [s@macro-user-callerid:39] GotoIf(“SIP/callcentric.com-00000018”, “0?cnum”) in new stack
– Executing [s@macro-user-callerid:40] Set(“SIP/callcentric.com-00000018”, “CDR(cnam)=+192xxxxxxxxxx”) in new stack
– Executing [s@macro-user-callerid:41] Set(“SIP/callcentric.com-00000018”, “CDR(cnum)=+192xxxxxxxxxx”) in new stack
– Executing [s@macro-user-callerid:42] Set(“SIP/callcentric.com-00000018”, “CHANNEL(language)=en”) in new stack
– Executing [s@macro-exten-vm:2] Set(“SIP/callcentric.com-00000018”, “RingGroupMethod=none”) in new stack
– Executing [s@macro-exten-vm:3] Set(“SIP/callcentric.com-00000018”, “__EXTTOCALL=149”) in new stack
– Executing [s@macro-exten-vm:4] Set(“SIP/callcentric.com-00000018”, “__PICKUPMARK=149”) in new stack
– Executing [s@macro-exten-vm:5] Set(“SIP/callcentric.com-00000018”, “RT=”) in new stack
[2018-05-23 15:53:45] ERROR[43441][C-0000001c]: res_pjsip_header_funcs.c:461 func_read_header: This function requires a PJSIP channel.
** – Executing [s@macro-exten-vm:6] ExecIf(“SIP/callcentric.com-00000018”, “0?Macro(vm,novm,DIRECTDIAL,)”) in new stack**
[2018-05-23 15:53:45] ERROR[43441][C-0000001c]: res_pjsip_header_funcs.c:461 func_read_header: This function requires a PJSIP channel.
[2018-05-23 15:53:45] ERROR[43441][C-0000001c]: res_pjsip_header_funcs.c:461 func_read_header: This function requires a PJSIP channel.
– Executing [s@macro-exten-vm:7] ExecIf(“SIP/callcentric.com-00000018”, “0?MacroExit()”) in new stack
[2018-05-23 15:53:45] ERROR[43441][C-0000001c]: res_pjsip_header_funcs.c:461 func_read_header: This function requires a PJSIP channel.
[2018-05-23 15:53:45] ERROR[43441][C-0000001c]: res_pjsip_header_funcs.c:461 func_read_header: This function requires a PJSIP channel.
– Executing [s@macro-exten-vm:8] ExecIf(“SIP/callcentric.com-00000018”, “0?Gosub(ext-intercom,*80149,1())”) in new stack
[2018-05-23 15:53:45] ERROR[43441][C-0000001c]: res_pjsip_header_funcs.c:461 func_read_header: This function requires a PJSIP channel.
[2018-05-23 15:53:45] ERROR[43441][C-0000001c]: res_pjsip_header_funcs.c:461 func_read_header: This function requires a PJSIP channel.
– Executing [s@macro-exten-vm:9] ExecIf(“SIP/callcentric.com-00000018”, “0?MacroExit()”) in new stack
[2018-05-23 15:53:45] ERROR[43441][C-0000001c]: res_pjsip_header_funcs.c:461 func_read_header: This function requires a PJSIP channel.
[2018-05-23 15:53:45] ERROR[43441][C-0000001c]: res_pjsip_header_funcs.c:461 func_read_header: This function requires a PJSIP channel.
– Executing [s@macro-exten-vm:10] ExecIf(“SIP/callcentric.com-00000018”, “0?ChanSpy(PJSIP/149,q)”) in new stack
[2018-05-23 15:53:45] ERROR[43441][C-0000001c]: res_pjsip_header_funcs.c:461 func_read_header: This function requires a PJSIP channel.
[2018-05-23 15:53:45] ERROR[43441][C-0000001c]: res_pjsip_header_funcs.c:461 func_read_header: This function requires a PJSIP channel.
– Executing [s@macro-exten-vm:11] ExecIf(“SIP/callcentric.com-00000018”, “0?MacroExit()”) in new stack
[2018-05-23 15:53:45] ERROR[43441][C-0000001c]: res_pjsip_header_funcs.c:461 func_read_header: This function requires a PJSIP channel.
– Executing [s@macro-exten-vm:12] Gosub(“SIP/callcentric.com-00000018”, “sub-record-check,s,1(exten,149,dontcare)”) in new stack
– Executing [s@sub-record-check:1] GotoIf(“SIP/callcentric.com-00000018”, “14?initialized”) in new stack
– Goto (sub-record-check,s,10)
– Executing [s@sub-record-check:10] NoOp(“SIP/callcentric.com-00000018”, “Recordings initialized”) in new stack
– Executing [s@sub-record-check:11] ExecIf(“SIP/callcentric.com-00000018”, “0?Set(ARG3=dontcare)”) in new stack
– Executing [s@sub-record-check:12] Set(“SIP/callcentric.com-00000018”, “REC_POLICY_MODE_SAVE=NO”) in new stack
– Executing [s@sub-record-check:13] ExecIf(“SIP/callcentric.com-00000018”, “0?Set(REC_STATUS=NO)”) in new stack
– Executing [s@sub-record-check:14] GotoIf(“SIP/callcentric.com-00000018”, “5?checkaction”) in new stack
– Goto (sub-record-check,s,17)
– Executing [s@sub-record-check:17] GotoIf(“SIP/callcentric.com-00000018”, “1?sub-record-check,exten,1”) in new stack
– Goto (sub-record-check,exten,1)
– Executing [exten@sub-record-check:1] NoOp(“SIP/callcentric.com-00000018”, “Exten Recording Check between +192xxxxxxxxxx and 149”) in new stack
– Executing [exten@sub-record-check:2] Set(“SIP/callcentric.com-00000018”, “CALLTYPE=external”) in new stack
– Executing [exten@sub-record-check:3] ExecIf(“SIP/callcentric.com-00000018”, “0?Set(CALLTYPE=)”) in new stack
– Executing [exten@sub-record-check:4] Set(“SIP/callcentric.com-00000018”, “CALLEE=dontcare”) in new stack
– Executing [exten@sub-record-check:5] ExecIf(“SIP/callcentric.com-00000018”, “0?Set(CALLEE=dontcare)”) in new stack
– Executing [exten@sub-record-check:6] GotoIf(“SIP/callcentric.com-00000018”, “1?callee”) in new stack
– Goto (sub-record-check,exten,11)
– Executing [exten@sub-record-check:11] Gosub(“SIP/callcentric.com-00000018”, “recordcheck,1(dontcare,external,149)”) in new stack
– Executing [recordcheck@sub-record-check:1] NoOp(“SIP/callcentric.com-00000018”, “Starting recording check against dontcare”) in new stack
– Executing [recordcheck@sub-record-check:2] Goto(“SIP/callcentric.com-00000018”, “dontcare”) in new stack
– Goto (sub-record-check,recordcheck,3)
– Executing [recordcheck@sub-record-check:3] Return(“SIP/callcentric.com-00000018”, “”) in new stack
– Executing [exten@sub-record-check:12] Return(“SIP/callcentric.com-00000018”, “”) in new stack
– Executing [s@macro-exten-vm:13] GotoIf(“SIP/callcentric.com-00000018”, “1?macrodial”) in new stack
– Goto (macro-exten-vm,s,19)
– Executing [s@macro-exten-vm:19] GosubIf(“SIP/callcentric.com-00000018”, “0?clrheader,1()”) in new stack
– Executing [s@macro-exten-vm:20] Macro(“SIP/callcentric.com-00000018”, “dial-one,HhTtr,149”) in new stack
– Executing [s@macro-dial-one:1] Set(“SIP/callcentric.com-00000018”, “DEXTEN=149”) in new stack
– Executing [s@macro-dial-one:2] Set(“SIP/callcentric.com-00000018”, “__CRM_SOURCE=+192xxxxxxxxxx”) in new stack
– Executing [s@macro-dial-one:3] ExecIf(“SIP/callcentric.com-00000018”, “0?Set(EXTTOCALL=149)”) in new stack
– Executing [s@macro-dial-one:4] Set(“SIP/callcentric.com-00000018”, “DIALSTATUS_CW=”) in new stack
– Executing [s@macro-dial-one:5] GosubIf(“SIP/callcentric.com-00000018”, “0?screen,1()”) in new stack
– Executing [s@macro-dial-one:6] GosubIf(“SIP/callcentric.com-00000018”, “0?cf,1()”) in new stack
– Executing [s@macro-dial-one:7] GotoIf(“SIP/callcentric.com-00000018”, “1?skip1”) in new stack
– Goto (macro-dial-one,s,10)
– Executing [s@macro-dial-one:10] GotoIf(“SIP/callcentric.com-00000018”, “0?nodial”) in new stack
– Executing [s@macro-dial-one:11] GotoIf(“SIP/callcentric.com-00000018”, “0?continue”) in new stack
– Executing [s@macro-dial-one:12] Set(“SIP/callcentric.com-00000018”, “EXTHASCW=ENABLED”) in new stack
– Executing [s@macro-dial-one:13] GotoIf(“SIP/callcentric.com-00000018”, “0?next1:cwinusebusy”) in new stack
– Goto (macro-dial-one,s,25)
– Executing [s@macro-dial-one:25] GotoIf(“SIP/callcentric.com-00000018”, “0?next3:continue”) in new stack
– Goto (macro-dial-one,s,27)
– Executing [s@macro-dial-one:27] GotoIf(“SIP/callcentric.com-00000018”, “0?nodial”) in new stack
– Executing [s@macro-dial-one:28] GosubIf(“SIP/callcentric.com-00000018”, “1?dstring,1():dlocal,1()”) in new stack
– Executing [dstring@macro-dial-one:1] Set(“SIP/callcentric.com-00000018”, “DSTRING=”) in new stack
– Executing [dstring@macro-dial-one:2] Set(“SIP/callcentric.com-00000018”, “DEVICES=149”) in new stack
– Executing [dstring@macro-dial-one:3] ExecIf(“SIP/callcentric.com-00000018”, “0?Return()”) in new stack
– Executing [dstring@macro-dial-one:4] ExecIf(“SIP/callcentric.com-00000018”, “0?Set(DEVICES=49)”) in new stack
– Executing [dstring@macro-dial-one:5] Set(“SIP/callcentric.com-00000018”, “LOOPCNT=1”) in new stack
– Executing [dstring@macro-dial-one:6] Set(“SIP/callcentric.com-00000018”, “ITER=1”) in new stack
– Executing [dstring@macro-dial-one:7] Set(“SIP/callcentric.com-00000018”, “THISDIAL=PJSIP/149”) in new stack
– Executing [dstring@macro-dial-one:8] GosubIf(“SIP/callcentric.com-00000018”, “1?zap2dahdi,1()”) in new stack
– Executing [zap2dahdi@macro-dial-one:1] ExecIf(“SIP/callcentric.com-00000018”, “0?Return()”) in new stack
– Executing [zap2dahdi@macro-dial-one:2] Set(“SIP/callcentric.com-00000018”, “NEWDIAL=”) in new stack
– Executing [zap2dahdi@macro-dial-one:3] Set(“SIP/callcentric.com-00000018”, “LOOPCNT2=1”) in new stack
– Executing [zap2dahdi@macro-dial-one:4] Set(“SIP/callcentric.com-00000018”, “ITER2=1”) in new stack
– Executing [zap2dahdi@macro-dial-one:5] Set(“SIP/callcentric.com-00000018”, “THISPART2=PJSIP/149”) in new stack
– Executing [zap2dahdi@macro-dial-one:6] ExecIf(“SIP/callcentric.com-00000018”, “0?Set(THISPART2=DAHDIIP/149)”) in new stack
– Executing [zap2dahdi@macro-dial-one:7] Set(“SIP/callcentric.com-00000018”, “NEWDIAL=PJSIP/149&”) in new stack
– Executing [zap2dahdi@macro-dial-one:8] Set(“SIP/callcentric.com-00000018”, “ITER2=2”) in new stack
– Executing [zap2dahdi@macro-dial-one:9] GotoIf(“SIP/callcentric.com-00000018”, “0?begin2”) in new stack
– Executing [zap2dahdi@macro-dial-one:10] Set(“SIP/callcentric.com-00000018”, “THISDIAL=PJSIP/149”) in new stack
– Executing [zap2dahdi@macro-dial-one:11] Return(“SIP/callcentric.com-00000018”, “”) in new stack
– Executing [dstring@macro-dial-one:9] GotoIf(“SIP/callcentric.com-00000018”, “0?docheck”) in new stack
– Executing [dstring@macro-dial-one:10] NoOp(“SIP/callcentric.com-00000018”, “Debug: Found PJSIP Destination PJSIP/149”) in new stack
– Executing [dstring@macro-dial-one:11] GotoIf(“SIP/callcentric.com-00000018”, “0?doset”) in new stack
– Executing [dstring@macro-dial-one:12] NoOp(“SIP/callcentric.com-00000018”, “Debug: Updating PJSIP Destination with PJSIP_DIAL_CONTACTS”) in new stack
– Executing [dstring@macro-dial-one:13] Set(“SIP/callcentric.com-00000018”, “THISDIAL=PJSIP/149/sip:[email protected]:5060”) in new stack
– Executing [dstring@macro-dial-one:14] GotoIf(“SIP/callcentric.com-00000018”, “0?skipset”) in new stack
– Executing [dstring@macro-dial-one:15] Set(“SIP/callcentric.com-00000018”, “DSTRING=PJSIP/149/sip:[email protected]:5060&”) in new stack
– Executing [dstring@macro-dial-one:16] Set(“SIP/callcentric.com-00000018”, “ITER=2”) in new stack
– Executing [dstring@macro-dial-one:17] GotoIf(“SIP/callcentric.com-00000018”, “0?begin”) in new stack
– Executing [dstring@macro-dial-one:18] ExecIf(“SIP/callcentric.com-00000018”, “0?Return()”) in new stack
– Executing [dstring@macro-dial-one:19] Set(“SIP/callcentric.com-00000018”, “DSTRING=PJSIP/149/sip:[email protected]:5060”) in new stack
– Executing [dstring@macro-dial-one:20] Return(“SIP/callcentric.com-00000018”, “”) in new stack
– Executing [s@macro-dial-one:29] GotoIf(“SIP/callcentric.com-00000018”, “0?nodial”) in new stack
– Executing [s@macro-dial-one:30] GotoIf(“SIP/callcentric.com-00000018”, “0?skiptrace”) in new stack
– Executing [s@macro-dial-one:31] GosubIf(“SIP/callcentric.com-00000018”, “1?ctset,1():ctclear,1()”) in new stack
– Executing [ctset@macro-dial-one:1] Set(“SIP/callcentric.com-00000018”, “DB(CALLTRACE/149)=+192xxxxxxxxxx”) in new stack
– Executing [ctset@macro-dial-one:2] Return(“SIP/callcentric.com-00000018”, “”) in new stack
– Executing [s@macro-dial-one:32] Set(“SIP/callcentric.com-00000018”, “D_OPTIONS=HhTtr”) in new stack
– Executing [s@macro-dial-one:33] NoOp(“SIP/callcentric.com-00000018”, "Blind Transfer: , Attended Transfer: , User: , Alert Info: ") in new stack
– Executing [s@macro-dial-one:34] ExecIf(“SIP/callcentric.com-00000018”, “0?Set(ALERT_INFO=)”) in new stack
– Executing [s@macro-dial-one:35] ExecIf(“SIP/callcentric.com-00000018”, “0?Set(ALERT_INFO=)”) in new stack
– Executing [s@macro-dial-one:36] ExecIf(“SIP/callcentric.com-00000018”, “0?Set(ALERT_INFO=)”) in new stack
– Executing [s@macro-dial-one:37] ExecIf(“SIP/callcentric.com-00000018”, “0?Set(ALERT_INFO=Normal;volume=)”) in new stack
– Executing [s@macro-dial-one:38] ExecIf(“SIP/callcentric.com-00000018”, “0?Set(ALERT_INFO=Normal;volume=)”) in new stack
– Executing [s@macro-dial-one:39] GosubIf(“SIP/callcentric.com-00000018”, “0?func-set-sipheader,s,1(Alert-Info,)”) in new stack
– Executing [s@macro-dial-one:40] ExecIf(“SIP/callcentric.com-00000018”, “0?Set(CHANNEL(musicclass)=)”) in new stack
– Executing [s@macro-dial-one:41] GosubIf(“SIP/callcentric.com-00000018”, “0?qwait,1()”) in new stack
– Executing [s@macro-dial-one:42] Set(“SIP/callcentric.com-00000018”, “__CWIGNORE=”) in new stack
– Executing [s@macro-dial-one:43] Set(“SIP/callcentric.com-00000018”, “__KEEPCID=TRUE”) in new stack
– Executing [s@macro-dial-one:44] GotoIf(“SIP/callcentric.com-00000018”, “0?usegoto,1”) in new stack
– Executing [s@macro-dial-one:45] GotoIf(“SIP/callcentric.com-00000018”, “1?godial”) in new stack
– Goto (macro-dial-one,s,50)
– Executing [s@macro-dial-one:50] Macro(“SIP/callcentric.com-00000018”, “dialout-one-predial-hook,”) in new stack
– Executing [s@macro-dialout-one-predial-hook:1] MacroExit(“SIP/callcentric.com-00000018”, “”) in new stack
– Executing [s@macro-dial-one:51] ExecIf(“SIP/callcentric.com-00000018”, “1?Set(D_OPTIONS=HhtrI)”) in new stack
– Executing [s@macro-dial-one:52] NoOp(“SIP/callcentric.com-00000018”, “”) in new stack
– Executing [s@macro-dial-one:53] Dial(“SIP/callcentric.com-00000018”, “PJSIP/149/sip:[email protected]:5060,HhtrIb(func-apply-sipheaders^s^1)”) in new stack
– PJSIP/149-00000011 Internal Gosub(func-apply-sipheaders,s,1) start
– Executing [s@func-apply-sipheaders:1] ExecIf(“PJSIP/149-00000011”, “1?Set(CHANNEL(hangup_handler_push)=crm-hangup,s,1)”) in new stack
– Executing [s@func-apply-sipheaders:2] NoOp(“PJSIP/149-00000011”, “Applying SIP Headers to channel”) in new stack
– Executing [s@func-apply-sipheaders:3] Set(“PJSIP/149-00000011”, “SIPHEADERKEYS=”) in new stack
– Executing [s@func-apply-sipheaders:4] While(“PJSIP/149-00000011”, “0”) in new stack
– Jumping to priority 8
– Executing [s@func-apply-sipheaders:9] Return(“PJSIP/149-00000011”, “”) in new stack
== Spawn extension (from-internal, 149, 1) exited non-zero on ‘PJSIP/149-00000011’
– PJSIP/149-00000011 Internal Gosub(func-apply-sipheaders,s,1) complete GOSUB_RETVAL=
– Called PJSIP/149/sip:[email protected]:5060

Several things are different from what I had assumed:

Your DID forwarding is ‘looping’ back into Callcentric. What happened when you used the default setting?

You have enabled logging for pjsip but your trunk is chan_sip, so we didn’t see the actual SIP dialog.

Callcentric with Asterisk typically requires some special dial plan code, because they send calls from IP addresses other than the one to which you registered. By default, this would cause Asterisk to reject the call and play a ‘number not in service’ message. It seems that you have enabled anonymous calls as a workaround. This is a potential security issue that you should fix before putting the system into production. However, in this case it also caused the from-pstn-toheader context to not be executed, because the call was not identified as belonging to the CC trunk.

With DID forwarding at Default, Call Treatments off and sip set debug on issued, we can at least see whether CC is sending the DID number in the To header.

If your PBX has a static public IP address, a simple solution may be to set your DID forwarding:
161XXXXXXX1 -> 161XXXXXXX1@yourpbxip
44XXXXXXXX34 -> 44XXXXXXXX34@yourpbxip

(Put e.g. :5160 after the IP address, if you are running chan_sip on other than port 5060.)

You might find this thread useful: https://www.dslreports.com/forum/r31085468-CallCentric-Setup-with-FreePBX

Also https://www.callcentric.com/support/device/freepbx .

Dear Stewart,
Thanks for the prompt help once again. I will try your suggestion and update you. Meanwhile as you mentioned that my trunk is chan_sip , is it ok if i delete this trunk and create again with pjsip ? Will that fix any of our worries or thats just for the logging part ?

I tried a CC trunk on my test system with pjsip and it seemed to work well. However, I’m running Asterisk 14.7.5, which may make a difference. Also, my testing was quite limited; there may be problems when you stress it.

Only one trunk was used. Non-default settings:
Trunk Name: Callcentric
Outbound CallerID: (your main number)
Username: (your 1777XXXXXXX number)
Secret: (your SIP password)
SIP Server: callcentric.com
Context: from-pstn-toheader
From User: (your 1777XXXXXXX number)
Send RPID/PAI: Send Remote-Party-ID header

On CC portal, DID Forwarding set to Default for all DIDs; Call Treatments turned off.

With luck, incoming should now be working.

For outgoing, each Outbound Route that uses the CC trunk should have:
Route CID: (the DID number you want to display for that route)
Override Extension: Yes

1 Like