External calls are not routed to the extension

Hello,
I have installed FreePBX 16.0.40.7 with Asterisk 20.5.0. The extensions work internally. Only when I call a number externally does Alison Voice come every time and report that the number does not exist.
I did the configuration according to this guide:
https://blog.griebsch.de/freepbx-15-asterisk-16-teil-3-config-der-nebenstellen-und-routen/
Here is a log from an external call:

Connected to Asterisk 20.5.0 currently running on freepbx (pid = 1276)
    -- Executing [715256891@from-pstn-pciheader:1] Set("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "Format=Format1") in new stack
    -- Executing [715256891@from-pstn-pciheader:2] NoOp("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "Attempting to extract DID from SIP PCI header") in new stack
    -- Executing [715256891@from-pstn-pciheader:3] NoOp("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "SIP From: <sip:[email protected];user=phone>;tag=p65559t1704046268m17510c83677s1_813480717-287111541") in new stack
    -- Executing [715256891@from-pstn-pciheader:4] NoOp("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "SIP To  : <sip:[email protected];user=phone>") in new stack
    -- Executing [715256891@from-pstn-pciheader:5] NoOp("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "SIP P-Called-Party-ID  : ") in new stack
    -- Executing [715256891@from-pstn-pciheader:6] NoOp("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "SIP PAI : <sip:[email protected]:5060;user=phone>") in new stack
    -- Executing [715256891@from-pstn-pciheader:7] NoOp("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "SIP PPI : ") in new stack
    -- Executing [715256891@from-pstn-pciheader:8] NoOp("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "SIP Via  : SIP/2.0/TCP 217.0.146.197:5060;rport=5060;received=217.0.146.197;branch=z9hG4bKmavodi-0-264-c1-1-1000000-2cd0000-609938703cd35-c96-ffffffffffffffff-2ac-a2690000-6099386f461dd-813511225-18824") in new stack
    -- Executing [715256891@from-pstn-pciheader:9] NoOp("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "SIP Call-ID  : p65559t1704046268m17510c83677s2") in new stack
    -- Executing [715256891@from-pstn-pciheader:10] NoOp("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "SIP Subject  : ") in new stack
    -- Executing [715256891@from-pstn-pciheader:11] GotoIf("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "1?Format1") in new stack
    -- Goto (from-pstn-pciheader,715256891,15)
    -- Executing [715256891@from-pstn-pciheader:15] Goto("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "from-pstn,,1") in new stack
    -- Goto (from-pstn,715256891,1)
    -- Executing [715256891@from-pstn:1] Set("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "__FROM_DID=715256891") in new stack
    -- Executing [715256891@from-pstn:2] NoOp("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "Received an unknown call with DID set to 715256891") in new stack
    -- Executing [715256891@from-pstn:3] Goto("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "s,a2") in new stack
    -- Goto (from-pstn,s,2)
    -- Executing [s@from-pstn:2] Answer("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "") in new stack
       > 0x7f34012f80 -- Strict RTP learning after remote address set to: 217.0.167.45:49778
[2023-12-31 19:11:08] ERROR[63376][C-00000011]: pbx_functions.c:651 ast_func_read2: Function SIP_HEADER not registered
    -- Executing [s@from-pstn:3] Log("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "WARNING,Friendly Scanner from ") in new stack
[2023-12-31 19:11:08] WARNING[63376][C-00000011]: Ext. s:3 @ from-pstn: Friendly Scanner from 
    -- Executing [s@from-pstn:4] Wait("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "2") in new stack
       > 0x7f34012f80 -- Strict RTP switching to RTP target address 217.0.167.45:49778 as source
    -- Executing [s@from-pstn:5] Playback("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "ss-noservice") in new stack
    -- <PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017> Playing 'ss-noservice.g722' (language 'de_DE')
       > 0x7f34012f80 -- Strict RTP learning complete - Locking on source address 217.0.167.45:49778
    -- Added contact 'sip:[email protected]:40320;rinstance=1edf32836584bd28' to AOR '2280' with expiration of 60 seconds
    -- Contact 2280/sip:[email protected]:40320;rinstance=1edf32836584bd28 is now Reachable.  RTT: 8.124 msec
    -- Removed contact 'sip:[email protected]:40320;rinstance=b4ba856414d082e0' from AOR '2280' due to remove existing
  == Contact 2280/sip:[email protected]:40320;rinstance=b4ba856414d082e0 has been deleted
    -- Added contact 'sip:[email protected]:40320;rinstance=b4ba856414d082e0' to AOR '2280' with expiration of 60 seconds
    -- Removed contact 'sip:[email protected]:40320;rinstance=1edf32836584bd28' from AOR '2280' due to remove existing
  == Contact 2280/sip:[email protected]:40320;rinstance=1edf32836584bd28 has been deleted
  == Endpoint 2280 is now Unreachable
  == Endpoint 2280 is now Reachable
    -- Contact 2280/sip:[email protected]:40320;rinstance=b4ba856414d082e0 is now Reachable.  RTT: 293.268 msec
  == Spawn extension (from-pstn, s, 5) exited non-zero on 'PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017'
    -- Executing [h@from-pstn:1] Macro("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "hangupcall,") in new stack
    -- Executing [s@macro-hangupcall:1] GotoIf("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "1?theend") in new stack
    -- Goto (macro-hangupcall,s,3)
    -- Executing [s@macro-hangupcall:3] ExecIf("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "0?Set(CDR(recordingfile)=)") in new stack
    -- Executing [s@macro-hangupcall:4] Hangup("PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017", "") in new stack
  == Spawn extension (macro-hangupcall, s, 4) exited non-zero on 'PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017' in macro 'hangupcall'
  == Spawn extension (from-pstn, h, 1) exited non-zero on 'PJSIP/Deutsche_Telekom_SIP-Trunk_1-00000017'

Could this possibly be related to this PST-PCI header?

[from-pstn-pciheader]
; einheitliche Nummer im internationalen Format wird im Telekom SIP Trunk im Header P-Called-Party-ID übergeben
; im To-Header kommt die Nummer in unterschiedlichen Formaten
; Dieser Context muss im Trunk angegeben werden
;##################################################################
; NUMMERNFORMAT FESTLEGEN
; Format1 = +49....
; Format2 = 00...
exten =>  _.,1,Set(Format=Format1)
;##################################################################
exten =>  _.,n,NoOp(Attempting to extract DID from SIP PCI header)
exten =>  _.,n,NoOp(SIP From: ${PJSIP_HEADER(read,From)})
exten =>  _.,n,NoOp(SIP To  : ${PJSIP_HEADER(read,To)})
exten =>  _.,n,NoOp(SIP P-Called-Party-ID  : ${PJSIP_HEADER(read,P-Called-Party-ID)})
exten =>  _.,n,NoOp(SIP PAI : ${PJSIP_HEADER(read,P-Asserted-Identity)})
exten =>  _.,n,NoOp(SIP PPI : ${PJSIP_HEADER(read,P-Preferred-Identity)})
exten =>  _.,n,NoOp(SIP Via  : ${PJSIP_HEADER(read,Via)})
exten =>  _.,n,NoOp(SIP Call-ID  : ${PJSIP_HEADER(read,Call-ID)})
exten =>  _.,n,NoOp(SIP Subject  : ${PJSIP_HEADER(read,Subject)})
exten =>  _.,n,gotoif($["${Format}"="Format1"]?Format1)
exten =>  _.,n,gotoif($["${Format}"="Format2"]?Format2)
exten =>  _.,n,NoOp(Unable to determine SIP channel type)
exten =>  _.,n,goto(from-pstn,${EXTEN},1)
exten =>  _.,n(Format1),Goto(from-pstn,${CUT(CUT(PJSIP_HEADER(read,P-Called-Party-ID),@,1),:,2)},1)
exten =>  _.,n(Format2),Set(NUMMER1=${CUT(CUT(PJSIP_HEADER(read,P-Called-Party-ID),@,1),:,2)})
exten =>  _.,n,Set(NUMMER2=00${NUMMER1:1})
exten =>  _.,n,NoOp(N1  : ${NUMMER1})
exten =>  _.,n,NoOp(N2  : ${NUMMER2})
exten =>  _.,n(PJSIP),Goto(from-pstn,${NUMMER2},1)

I hope you have suggestions that will help me.

Happy New Year tonight!

Njuguna

You are attempting to set the DID from a header that isn’t present.

Thank you for answering. Does this mean, this script is possible wrong?

Please provide “pjsip set logger on” output for the incoming INVITE and indicate where the DID appears in it. The script seems to be OK for what it claims to do, so I assume that what it claims to do is the wrong thing.

Thank you for your support, I was now able to solve the problem myself.
I know “pjsip set logger on” but it didn’t help either. Only a banal comment from the forum operator on https://blog.griebsch.de/ helped. Someone else also had this problem with the instructions offered there. You really have to praise the howtos, but the structuring is more chaos than structure. Above all, there is no table of contents for all videos so that you can quickly verify which one is right for you.
I had stuck to Howto 2.1 (Telekom DeutschlandLAN), but I only found out that there is a Howto explicitly for my former ISDN connection Magenta (Part 2.2) through this banal comment.
Technically there is a huge difference between the two. In part 2.1 the dial patterns look completely different plus this from-pstn-pciheader script. In part 2.2 the moderator uses completely different patterns, even though it is the same telephone provider.
That’s why I couldn’t make any calls out, nor could the calls come in, even though the registration worked - even that differs in 2.1 from 2.2.
Although someone has put in a lot of work, unfortunately it’s not very structured.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.