PJSIP Inbound Routes, can't distinguish

I have a problem, I cannot distinguish my numbers with PJSIP, in order for any calls to come in I have to have a any DID/any CID inbound route. I’ve tried changing the context, but no luck. I am using a SIP trunk.

Normally on chan_sip for the context I would use


and then I would add this code below to extensions_custom.conf

exten => _.,1,Goto(from-trunk,${CUT(CUT(SIP_HEADER(To),@,1),:,2)},1)

However this isn’t working with PJSIP. Do I have to edit another file?

PS - I am using FreePBX12 and Asterisk 13.


Thanks, but I honesty don’t know which code block I should be using.

The difference is 'SIP_HEADER" is used for chan_sip, whilst PJSIP_HEADER is used for pjsip. However, I’m pretty sure you DON’T need that. The ‘To’ field, in the header, is the destination of the DID. Have a look at your logs of incoming calls, and it’ll say something like ‘Unkown Destination XYZ’ - that’s the To header.

Here’s an example inbound call that hits the PBX but get number unavailable message.

    -- Executing [[email protected]:1] NoOp("PJSIP/PROXIMITI-00000001", "No DID or CID Match") in new stack
    -- Executing [[email protected]:2] Answer("PJSIP/PROXIMITI-00000001", "") in new stack
[2015-02-10 19:38:16] WARNING[17983][C-00000004]: chan_sip.c:22217 func_header_read: This function can only be used on SIP channels.
    -- Executing [[email protected]:3] Log("PJSIP/PROXIMITI-00000001", "WARNING,Friendly Scanner from ") in new stack
[2015-02-10 19:38:16] WARNING[17983][C-00000004]: Ext. s:3 @ from-trunk: Friendly Scanner from
    -- Executing [[email protected]:4] Wait("PJSIP/PROXIMITI-00000001", "2") in new stack
       > 0x7faa80079530 -- Probation passed - setting RTP source address to
    -- Executing [[email protected]:5] Playback("PJSIP/PROXIMITI-00000001", "ss-noservice") in new stack
    -- <PJSIP/PROXIMITI-00000001> Playing 'ss-noservice.gsm' (language 'en')
    -- Executing [[email protected]:6] SayAlpha("PJSIP/PROXIMITI-00000001", "") in new stack
    -- Executing [[email protected]:7] Hangup("PJSIP/PROXIMITI-00000001", "") in new stack
  == Spawn extension (from-trunk, s, 7) exited non-zero on 'PJSIP/PROXIMITI-00000001'
    -- Executing [[email protected]:1] Macro("PJSIP/PROXIMITI-00000001", "hangupcall,") in new stack
    -- Executing [[email protected]:1] GotoIf("PJSIP/PROXIMITI-00000001", "1?theend") in new stack
    -- Goto (macro-hangupcall,s,3)
    -- Executing [[email protected]:3] ExecIf("PJSIP/PROXIMITI-00000001", "0?Set(CDR(recordingfile)=)") in new stack
    -- Executing [[email protected]:4] Hangup("PJSIP/PROXIMITI-00000001", "") in new stack
  == Spawn extension (macro-hangupcall, s, 4) exited non-zero on 'PJSIP/PROXIMITI-00000001' in macro 'hangupcall'
  == Spawn extension (from-trunk, h, 1) exited non-zero on 'PJSIP/PROXIMITI-00000001'

That means that it’s coming to ‘s’, usually. Do you have a catch-all DID set up? That’ll display the DID in the log. (Create an inbound route with DID and CallerID blank, and that’ll match everything)

My first inclination would be to replace SIP_HEADER with PJSIP_HEADER in your new [custom-get-did-from-pjsip], did you try that?