Issues with outgoing calling on pjsip: Could not create dialog to invalid URI

I’ve setup Asterisk 18 with pjsip to have several SIP clients registered, and also to register Asterisk with two external SIP servers: one is the SIP provider SIPGATE and the other is my hardware device AVM FritzBox which supports SIP endpoints.
The sip clients can talk internally. Asterisk also successfully receives incoming calls through both SIP providers. However, when trying to call externally from Asterisk through either SIP provider it fails for different reasons which I hope to get some help on.

In extensions.conf I routed every number that begins with 0 via sipgate:

exten => _0X.,1,Dial(PJSIP/sipgate/${EXTEN})

And every number that starts with 1234 is routed via FritzBox by stripping that prefix:
exten => _1234X.,1,Dial(PJSIP/${EXTEN:4}@myfritz)

When I want to call via Sipgate, I get:

-- Executing [08003301000@sammlung:1] Dial("PJSIP/6001-00000015", "PJSIP/sipgate/08003301000") in new stack
[Sep  5 15:49:29] ERROR[53773]: res_pjsip.c:848 ast_sip_create_dialog_uac: Endpoint 'sipgate': Could not create dialog to invalid URI '08003301000'.  Is endpoint registered and reachable?
[Sep  5 15:49:29] ERROR[53773]: chan_pjsip.c:2672 request: Failed to create outgoing session to endpoint 'sipgate'
[Sep  5 15:49:29] WARNING[53779][C-0000000f]: app_dial.c:2702 dial_exec_full: Unable to create channel of type 'PJSIP' (cause 3 - No route to destination)
    -- No devices or endpoints to dial (technology/resource)
    -- Auto fallthrough, channel 'PJSIP/6001-00000015' status is 'CHANUNAVAIL'

When I call via FritzBox I get:

  -- Executing [123408003301000@sammlung:1] Dial("PJSIP/6001-00000016", "PJSIP/08003301000@myfritz") in new stack
    -- Called PJSIP/08003301000@myfritz
  == Everyone is busy/congested at this time (1:0/0/1)
    -- Auto fallthrough, channel 'PJSIP/6001-00000016' status is 'CHANUNAVAIL'

When I activate more verbose logging in pjsip I see that FritzBox answers to Asterisk with SIP/404 response code.

Full state and logs follow:

> pjsip show registrations

 <Registration/ServerURI..............................>  <Auth....................>  <Status.......>
==========================================================================================

 myfritz/sip:622@192.168.23.1:5060                       myfritz                     Registered        (exp. 288s)
 reg_sipgate/sip:sipgate.de:5060                         auth_reg_sipgate            Registered        (exp. 56s)

Objects found: 2
> pjsip show endpoints

 Endpoint:  <Endpoint/CID.....................................>  <State.....>  <Channels.>
    I/OAuth:  <AuthId/UserName...........................................................>
        Aor:  <Aor............................................>  <MaxContact>
      Contact:  <Aor/ContactUri..........................> <Hash....> <Status> <RTT(ms)..>
  Transport:  <TransportId........>  <Type>  <cos>  <tos>  <BindAddress..................>
   Identify:  <Identify/Endpoint.........................................................>
        Match:  <criteria.........................>
    Channel:  <ChannelId......................................>  <State.....>  <Time.....>
        Exten: <DialedExten...........>  CLCID: <ConnectedLineCID.......>
==========================================================================================


 Endpoint:  6001                                                 Not in use    0 of inf
     InAuth:  6001/6001
        Aor:  6001                                               1
      Contact:  6001/sip:6001@192.168.23.24:38438;transpor 26f780e290 NonQual         nan

 Endpoint:  6002                                                 Unavailable   0 of inf
     InAuth:  6002/6002
        Aor:  6002                                               1

 Endpoint:  myfritz                                              Not in use    0 of inf
    OutAuth:  myfritz/622
        Aor:  myfritz                                            0
      Contact:  myfritz/sip:622@192.168.23.1:5060          92bf94073f NonQual         nan
   Identify:  myfritz/myfritz
        Match: 192.168.23.1/32

 Endpoint:  sipgate                                              Not in use    0 of inf
    OutAuth:  sipgate_auth/7279301
        Aor:  sipgate_aor                                        0
      Contact:  sipgate_aor/sip:7279301@sipgate.de         2b4eef55f9 NonQual         nan
   Identify:  sipgate_identity/sipgate
        Match: 217.10.79.9/32
        Match: 2001:ab7::1/128
        Match: 2001:ab7::4/128
        Match: 2001:ab7::3/128
        Match: 2001:ab7::2/128

Packet log when calling using Sipgate:

<--- Received SIP request (1173 bytes) from UDP:[192.168.23.24:38438](http://192.168.23.24:38438/) --->
INVITE [sip:08003301000@192.168.23.36](mailto:sip%3A08003301000@192.168.23.36) SIP/2.0
Via: SIP/2.0/UDP 192.168.23.24:38438;branch=z9hG4bK.NaWKc3Fqs;rport
From: <[sip:6001@192.168.23.36](mailto:sip%3A6001@192.168.23.36)>;tag=gsUGHyRqh
To: [sip:08003301000@192.168.23.36](mailto:sip%3A08003301000@192.168.23.36)
CSeq: 20 INVITE
Call-ID: jVuv3HIYnu
Max-Forwards: 70
Supported: replaces, outbound, gruu
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, PRACK, UPDATE
Content-Type: application/sdp
Content-Length: 519
Contact: <sip:6001@192.168.23.24:38438;transport=udp>;expires=3599;+sip.instance="<urn:uuid:99a4d7f3-6aaa-009f-9493-891cc83d6bbe>"
User-Agent: LinphoneAndroid/4.6.12 (Pixel 5) LinphoneSDK/5.1.51 (tags/5.1.51^0)

v=0
o=6001 455 3328 IN IP4 192.168.23.24
s=Talk
c=IN IP4 192.168.23.24
t=0 0
a=rtcp-xr:rcvr-rtt=all:10000 stat-summary=loss,dup,jitt,TTL voip-metrics
m=audio 7078 RTP/AVP 96 97 98 0 8 18 99 100 101
a=rtpmap:96 opus/48000/2
a=fmtp:96 useinbandfec=1
a=rtpmap:97 speex/16000
a=fmtp:97 vbr=on
a=rtpmap:98 speex/8000
a=fmtp:98 vbr=on
a=fmtp:18 annexb=yes
a=rtpmap:99 telephone-event/48000
a=rtpmap:100 telephone-event/16000
a=rtpmap:101 telephone-event/8000
a=rtcp-fb:* trr-int 1000
a=rtcp-fb:* ccm tmmbr

<--- Transmitting SIP response (465 bytes) to UDP:[192.168.23.24:38438](http://192.168.23.24:38438/) --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.23.24:38438;rport=38438;received=192.168.23.24;branch=z9hG4bK.NaWKc3Fqs
Call-ID: jVuv3HIYnu
From: <[sip:6001@192.168.23.36](mailto:sip%3A6001@192.168.23.36)>;tag=gsUGHyRqh
To: <[sip:08003301000@192.168.23.36](mailto:sip%3A08003301000@192.168.23.36)>;tag=z9hG4bK.NaWKc3Fqs
CSeq: 20 INVITE
WWW-Authenticate: Digest realm="asterisk",nonce="1662385769/8e966e46d57eaafbbbeefbd94a874c28",opaque="1fb7d1c20539b639",algorithm=MD5,qop="auth"
Server: Asterisk PBX 18.13.0
Content-Length: 0

<--- Received SIP request (404 bytes) from UDP:[192.168.23.24:38438](http://192.168.23.24:38438/) --->
ACK [sip:08003301000@192.168.23.36](mailto:sip%3A08003301000@192.168.23.36) SIP/2.0
Via: SIP/2.0/UDP 192.168.23.24:38438;branch=z9hG4bK.NaWKc3Fqs;rport
Call-ID: jVuv3HIYnu
From: <[sip:6001@192.168.23.36](mailto:sip%3A6001@192.168.23.36)>;tag=gsUGHyRqh
To: <[sip:08003301000@192.168.23.36](mailto:sip%3A08003301000@192.168.23.36)>;tag=z9hG4bK.NaWKc3Fqs
Contact: <sip:6001@192.168.23.24:38438;transport=udp>;expires=3599;+sip.instance="<urn:uuid:99a4d7f3-6aaa-009f-9493-891cc83d6bbe>"
Max-Forwards: 70
CSeq: 20 ACK

<--- Received SIP request (1459 bytes) from UDP:[192.168.23.24:38438](http://192.168.23.24:38438/) --->
INVITE [sip:08003301000@192.168.23.36](mailto:sip%3A08003301000@192.168.23.36) SIP/2.0
Via: SIP/2.0/UDP 192.168.23.24:38438;branch=z9hG4bK.ugErKQaDD;rport
From: <[sip:6001@192.168.23.36](mailto:sip%3A6001@192.168.23.36)>;tag=gsUGHyRqh
To: [sip:08003301000@192.168.23.36](mailto:sip%3A08003301000@192.168.23.36)
CSeq: 21 INVITE
Call-ID: jVuv3HIYnu
Max-Forwards: 70
Supported: replaces, outbound, gruu
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, PRACK, UPDATE
Content-Type: application/sdp
Content-Length: 519
Contact: <sip:6001@192.168.23.24:38438;transport=udp>;expires=3599;+sip.instance="<urn:uuid:99a4d7f3-6aaa-009f-9493-891cc83d6bbe>"
User-Agent: LinphoneAndroid/4.6.12 (Pixel 5) LinphoneSDK/5.1.51 (tags/5.1.51^0)
Authorization: Digest realm="asterisk", nonce="1662385769/8e966e46d57eaafbbbeefbd94a874c28", algorithm=MD5, opaque="1fb7d1c20539b639", username="6001", uri="[sip:08003301000@192.168.23.36](mailto:sip%3A08003301000@192.168.23.36)", response="1fb9827f8abac377b4dbd1781841ff21", cnonce="NB2PajwZp9j3W6UF", nc=00000001, qop=auth

v=0
o=6001 455 3328 IN IP4 192.168.23.24
s=Talk
c=IN IP4 192.168.23.24
t=0 0
a=rtcp-xr:rcvr-rtt=all:10000 stat-summary=loss,dup,jitt,TTL voip-metrics
m=audio 7078 RTP/AVP 96 97 98 0 8 18 99 100 101
a=rtpmap:96 opus/48000/2
a=fmtp:96 useinbandfec=1
a=rtpmap:97 speex/16000
a=fmtp:97 vbr=on
a=rtpmap:98 speex/8000
a=fmtp:98 vbr=on
a=fmtp:18 annexb=yes
a=rtpmap:99 telephone-event/48000
a=rtpmap:100 telephone-event/16000
a=rtpmap:101 telephone-event/8000
a=rtcp-fb:* trr-int 1000
a=rtcp-fb:* ccm tmmbr

<--- Transmitting SIP response (291 bytes) to UDP:[192.168.23.24:38438](http://192.168.23.24:38438/) --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.23.24:38438;rport=38438;received=192.168.23.24;branch=z9hG4bK.ugErKQaDD
Call-ID: jVuv3HIYnu
From: <[sip:6001@192.168.23.36](mailto:sip%3A6001@192.168.23.36)>;tag=gsUGHyRqh
To: <[sip:08003301000@192.168.23.36](mailto:sip%3A08003301000@192.168.23.36)>
CSeq: 21 INVITE
Server: Asterisk PBX 18.13.0
Content-Length: 0

-- Executing [08003301000@sammlung:1] Dial("PJSIP/6001-00000015", "PJSIP/sipgate/08003301000") in new stack
[Sep 5 15:49:29] ERROR[53773]: res_pjsip.c:848 ast_sip_create_dialog_uac: Endpoint 'sipgate': Could not create dialog to invalid URI '08003301000'. Is endpoint registered and reachable?
[Sep 5 15:49:29] ERROR[53773]: chan_pjsip.c:2672 request: Failed to create outgoing session to endpoint 'sipgate'
[Sep 5 15:49:29] WARNING[53779][C-0000000f]: app_dial.c:2702 dial_exec_full: Unable to create channel of type 'PJSIP' (cause 3 - No route to destination)
-- No devices or endpoints to dial (technology/resource)
-- Auto fallthrough, channel 'PJSIP/6001-00000015' status is 'CHANUNAVAIL'
<--- Transmitting SIP response (368 bytes) to UDP:[192.168.23.24:38438](http://192.168.23.24:38438/) --->
SIP/2.0 503 Service Unavailable
Via: SIP/2.0/UDP 192.168.23.24:38438;rport=38438;received=192.168.23.24;branch=z9hG4bK.ugErKQaDD
Call-ID: jVuv3HIYnu
From: <[sip:6001@192.168.23.36](mailto:sip%3A6001@192.168.23.36)>;tag=gsUGHyRqh
To: <[sip:08003301000@192.168.23.36](mailto:sip%3A08003301000@192.168.23.36)>;tag=6b3b3e77-1e55-49a2-b9ec-c9ebb2186f75
CSeq: 21 INVITE
Server: Asterisk PBX 18.13.0
Reason: Q.850;cause=3
Content-Length: 0

<--- Received SIP request (423 bytes) from UDP:[192.168.23.24:38438](http://192.168.23.24:38438/) --->
ACK [sip:08003301000@192.168.23.36](mailto:sip%3A08003301000@192.168.23.36) SIP/2.0
Via: SIP/2.0/UDP 192.168.23.24:38438;branch=z9hG4bK.ugErKQaDD;rport
Call-ID: jVuv3HIYnu
From: <[sip:6001@192.168.23.36](mailto:sip%3A6001@192.168.23.36)>;tag=gsUGHyRqh
To: <[sip:08003301000@192.168.23.36](mailto:sip%3A08003301000@192.168.23.36)>;tag=6b3b3e77-1e55-49a2-b9ec-c9ebb2186f75
Contact: <sip:6001@192.168.23.24:38438;transport=udp>;expires=3599;+sip.instance="<urn:uuid:99a4d7f3-6aaa-009f-9493-891cc83d6bbe>"
Max-Forwards: 70
CSeq: 21 ACK

Packet log when calling via FritzBox

<--- Received SIP request (1180 bytes) from UDP:[192.168.23.24:38438](http://192.168.23.24:38438/) --->
INVITE [sip:123408003301000@192.168.23.36](mailto:sip%3A123408003301000@192.168.23.36) SIP/2.0
Via: SIP/2.0/UDP 192.168.23.24:38438;branch=z9hG4bK.Xb1UqcHMK;rport
From: <[sip:6001@192.168.23.36](mailto:sip%3A6001@192.168.23.36)>;tag=IrZXq2KxI
To: [sip:123408003301000@192.168.23.36](mailto:sip%3A123408003301000@192.168.23.36)
CSeq: 20 INVITE
Call-ID: 9O8E3Ng69u
Max-Forwards: 70
Supported: replaces, outbound, gruu
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, PRACK, UPDATE
Content-Type: application/sdp
Content-Length: 518
Contact: <sip:6001@192.168.23.24:38438;transport=udp>;expires=3599;+sip.instance="<urn:uuid:99a4d7f3-6aaa-009f-9493-891cc83d6bbe>"
User-Agent: LinphoneAndroid/4.6.12 (Pixel 5) LinphoneSDK/5.1.51 (tags/5.1.51^0)

v=0
o=6001 515 128 IN IP4 192.168.23.24
s=Talk
c=IN IP4 192.168.23.24
t=0 0
a=rtcp-xr:rcvr-rtt=all:10000 stat-summary=loss,dup,jitt,TTL voip-metrics
m=audio 7078 RTP/AVP 96 97 98 0 8 18 99 100 101
a=rtpmap:96 opus/48000/2
a=fmtp:96 useinbandfec=1
a=rtpmap:97 speex/16000
a=fmtp:97 vbr=on
a=rtpmap:98 speex/8000
a=fmtp:98 vbr=on
a=fmtp:18 annexb=yes
a=rtpmap:99 telephone-event/48000
a=rtpmap:100 telephone-event/16000
a=rtpmap:101 telephone-event/8000
a=rtcp-fb:* trr-int 1000
a=rtcp-fb:* ccm tmmbr

<--- Transmitting SIP response (469 bytes) to UDP:[192.168.23.24:38438](http://192.168.23.24:38438/) --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.23.24:38438;rport=38438;received=192.168.23.24;branch=z9hG4bK.Xb1UqcHMK
Call-ID: 9O8E3Ng69u
From: <[sip:6001@192.168.23.36](mailto:sip%3A6001@192.168.23.36)>;tag=IrZXq2KxI
To: <[sip:123408003301000@192.168.23.36](mailto:sip%3A123408003301000@192.168.23.36)>;tag=z9hG4bK.Xb1UqcHMK
CSeq: 20 INVITE
WWW-Authenticate: Digest realm="asterisk",nonce="1662385860/5f7ee5251f26c656b73640380213af03",opaque="5b6483f7410911e2",algorithm=MD5,qop="auth"
Server: Asterisk PBX 18.13.0
Content-Length: 0

<--- Received SIP request (412 bytes) from UDP:[192.168.23.24:38438](http://192.168.23.24:38438/) --->
ACK [sip:123408003301000@192.168.23.36](mailto:sip%3A123408003301000@192.168.23.36) SIP/2.0
Via: SIP/2.0/UDP 192.168.23.24:38438;branch=z9hG4bK.Xb1UqcHMK;rport
Call-ID: 9O8E3Ng69u
From: <[sip:6001@192.168.23.36](mailto:sip%3A6001@192.168.23.36)>;tag=IrZXq2KxI
To: <[sip:123408003301000@192.168.23.36](mailto:sip%3A123408003301000@192.168.23.36)>;tag=z9hG4bK.Xb1UqcHMK
Contact: <sip:6001@192.168.23.24:38438;transport=udp>;expires=3599;+sip.instance="<urn:uuid:99a4d7f3-6aaa-009f-9493-891cc83d6bbe>"
Max-Forwards: 70
CSeq: 20 ACK

<--- Received SIP request (1470 bytes) from UDP:[192.168.23.24:38438](http://192.168.23.24:38438/) --->
INVITE [sip:123408003301000@192.168.23.36](mailto:sip%3A123408003301000@192.168.23.36) SIP/2.0
Via: SIP/2.0/UDP 192.168.23.24:38438;branch=z9hG4bK.7RaNVWdwl;rport
From: <[sip:6001@192.168.23.36](mailto:sip%3A6001@192.168.23.36)>;tag=IrZXq2KxI
To: [sip:123408003301000@192.168.23.36](mailto:sip%3A123408003301000@192.168.23.36)
CSeq: 21 INVITE
Call-ID: 9O8E3Ng69u
Max-Forwards: 70
Supported: replaces, outbound, gruu
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, PRACK, UPDATE
Content-Type: application/sdp
Content-Length: 518
Contact: <sip:6001@192.168.23.24:38438;transport=udp>;expires=3599;+sip.instance="<urn:uuid:99a4d7f3-6aaa-009f-9493-891cc83d6bbe>"
User-Agent: LinphoneAndroid/4.6.12 (Pixel 5) LinphoneSDK/5.1.51 (tags/5.1.51^0)
Authorization: Digest realm="asterisk", nonce="1662385860/5f7ee5251f26c656b73640380213af03", algorithm=MD5, opaque="5b6483f7410911e2", username="6001", uri="[sip:123408003301000@192.168.23.36](mailto:sip%3A123408003301000@192.168.23.36)", response="23f311168760a445e899a0254e4360e1", cnonce="o2ClokZlEB8zTqUx", nc=00000001, qop=auth

v=0
o=6001 515 128 IN IP4 192.168.23.24
s=Talk
c=IN IP4 192.168.23.24
t=0 0
a=rtcp-xr:rcvr-rtt=all:10000 stat-summary=loss,dup,jitt,TTL voip-metrics
m=audio 7078 RTP/AVP 96 97 98 0 8 18 99 100 101
a=rtpmap:96 opus/48000/2
a=fmtp:96 useinbandfec=1
a=rtpmap:97 speex/16000
a=fmtp:97 vbr=on
a=rtpmap:98 speex/8000
a=fmtp:98 vbr=on
a=fmtp:18 annexb=yes
a=rtpmap:99 telephone-event/48000
a=rtpmap:100 telephone-event/16000
a=rtpmap:101 telephone-event/8000
a=rtcp-fb:* trr-int 1000
a=rtcp-fb:* ccm tmmbr

<--- Transmitting SIP response (295 bytes) to UDP:[192.168.23.24:38438](http://192.168.23.24:38438/) --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.23.24:38438;rport=38438;received=192.168.23.24;branch=z9hG4bK.7RaNVWdwl
Call-ID: 9O8E3Ng69u
From: <[sip:6001@192.168.23.36](mailto:sip%3A6001@192.168.23.36)>;tag=IrZXq2KxI
To: <[sip:123408003301000@192.168.23.36](mailto:sip%3A123408003301000@192.168.23.36)>
CSeq: 21 INVITE
Server: Asterisk PBX 18.13.0
Content-Length: 0

-- Executing [123408003301000@sammlung:1] Dial("PJSIP/6001-00000016", "PJSIP/08003301000@myfritz") in new stack
<--- Transmitting SIP request (963 bytes) to UDP:[192.168.23.1:5060](http://192.168.23.1:5060/) --->
INVITE [sip:08003301000@192.168.23.1:5060](http://sip:08003301000@192.168.23.1:5060/) SIP/2.0
Via: SIP/2.0/UDP 192.168.23.36:5060;rport;branch=z9hG4bKPj289510b1-eb38-41a1-99aa-d270d4cfd2da
From: <[sip:6001@192.168.23.36](mailto:sip%3A6001@192.168.23.36)>;tag=9c4c678e-ba08-4ff1-8025-6a82a12c441b
To: <[sip:08003301000@192.168.23.1](mailto:sip%3A08003301000@192.168.23.1)>
Contact: <[sip:asterisk@192.168.23.36:5060](http://sip:asterisk@192.168.23.36:5060/)>
Call-ID: 96bef885-654f-4129-b87f-bcbb9aae1051
CSeq: 5990 INVITE
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub, histinfo
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 18.13.0
Content-Type: application/sdp
Content-Length: 286

v=0
o=- 1908135872 1908135872 IN IP4 192.168.23.36
s=Asterisk
c=IN IP4 192.168.23.36
t=0 0
m=audio 17408 RTP/AVP 0 8 3 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

-- Called PJSIP/08003301000@myfritz
<--- Received SIP response (363 bytes) from UDP:[192.168.23.1:5060](http://192.168.23.1:5060/) --->
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 192.168.23.36:5060;rport=5060;branch=z9hG4bKPj289510b1-eb38-41a1-99aa-d270d4cfd2da
From: <[sip:6001@192.168.23.36](mailto:sip%3A6001@192.168.23.36)>;tag=9c4c678e-ba08-4ff1-8025-6a82a12c441b
To: <[sip:08003301000@192.168.23.1](mailto:sip%3A08003301000@192.168.23.1)>;tag=06B875C8404BE120
Call-ID: 96bef885-654f-4129-b87f-bcbb9aae1051
CSeq: 5990 INVITE
User-Agent: FRITZ!OS
Content-Length: 0

<--- Transmitting SIP request (410 bytes) to UDP:[192.168.23.1:5060](http://192.168.23.1:5060/) --->
ACK [sip:08003301000@192.168.23.1:5060](http://sip:08003301000@192.168.23.1:5060/) SIP/2.0
Via: SIP/2.0/UDP 192.168.23.36:5060;rport;branch=z9hG4bKPj289510b1-eb38-41a1-99aa-d270d4cfd2da
From: <[sip:6001@192.168.23.36](mailto:sip%3A6001@192.168.23.36)>;tag=9c4c678e-ba08-4ff1-8025-6a82a12c441b
To: <[sip:08003301000@192.168.23.1](mailto:sip%3A08003301000@192.168.23.1)>;tag=06B875C8404BE120
Call-ID: 96bef885-654f-4129-b87f-bcbb9aae1051
CSeq: 5990 ACK
Max-Forwards: 70
User-Agent: Asterisk PBX 18.13.0
Content-Length: 0

== Everyone is busy/congested at this time (1:0/0/1)
-- Auto fallthrough, channel 'PJSIP/6001-00000016' status is 'CHANUNAVAIL'
<--- Transmitting SIP response (373 bytes) to UDP:[192.168.23.24:38438](http://192.168.23.24:38438/) --->
SIP/2.0 503 Service Unavailable
Via: SIP/2.0/UDP 192.168.23.24:38438;rport=38438;received=192.168.23.24;branch=z9hG4bK.7RaNVWdwl
Call-ID: 9O8E3Ng69u
From: <[sip:6001@192.168.23.36](mailto:sip%3A6001@192.168.23.36)>;tag=IrZXq2KxI
To: <[sip:123408003301000@192.168.23.36](mailto:sip%3A123408003301000@192.168.23.36)>;tag=a3a9d948-a037-4d24-9f98-8fd2e1e0550f
CSeq: 21 INVITE
Server: Asterisk PBX 18.13.0
Reason: Q.850;cause=34
Content-Length: 0

<--- Received SIP request (431 bytes) from UDP:[192.168.23.24:38438](http://192.168.23.24:38438/) --->
ACK [sip:123408003301000@192.168.23.36](mailto:sip%3A123408003301000@192.168.23.36) SIP/2.0
Via: SIP/2.0/UDP 192.168.23.24:38438;branch=z9hG4bK.7RaNVWdwl;rport
Call-ID: 9O8E3Ng69u
From: <[sip:6001@192.168.23.36](mailto:sip%3A6001@192.168.23.36)>;tag=IrZXq2KxI
To: <[sip:123408003301000@192.168.23.36](mailto:sip%3A123408003301000@192.168.23.36)>;tag=a3a9d948-a037-4d24-9f98-8fd2e1e0550f
Contact: <sip:6001@192.168.23.24:38438;transport=udp>;expires=3599;+sip.instance="<urn:uuid:99a4d7f3-6aaa-009f-9493-891cc83d6bbe>"
Max-Forwards: 70
CSeq: 21 ACK

Many thanks for any help.

Please use pre-formatted, not quoted, markup for logs etc.

I don’t think you have used client and server with their SIP meanings.

The reason that sipgate fails is that you didn’t use the dialstring format you used for Frtizbox.

You are stripping the 1234 before calling Fritzbox. If it doesn’t like the resulting 0800330100, that isn’t an Asterisk problem.

Thanks a lot.

The problem with sipgate was indeed fixed by using the dialstring Dial(PJSIP/${EXTEN}@sipgate) and not the syntax PJSIP/sipgate/${EXTEN}.

The problem with FritzBox remains weird to me, as other SIP clients registered to it, as well as POTS phones directly connected to it, work with a phone number dialed in the national format.

I tried to use a full globalized E.164 format by configuring:

exten => _12340X.,1,Dial(PJSIP/+49${EXTEN:5}@myfritz)

but this gives the same 404:

  --- Called PJSIP/+498003301000@myfritz
<--- Received SIP response (365 bytes) from UDP:192.168.23.1:5060 --->
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 192.168.23.36:5060;rport=5060;branch=z9hG4bKPj84c298d0-67c5-4a4e-a0fe-5584596d29d1
From: <sip:6001@192.168.23.36>;tag=4f1d15ec-0333-4cce-b0d4-4e8b3cfcc593
To: <sip:+498003301000@192.168.23.1>;tag=9578DF2B69D00FAD
Call-ID: e9b8af57-08ab-44e6-816c-3975b5ab2029
CSeq: 1979 INVITE
User-Agent: FRITZ!OS
Content-Length: 0

Now you might say this isn’t Asterisk’s issue, but as said, I can register softphones with the same data and they call out fine. Maybe 404 is issued not only on incorrect number but also on some other situations that are caued by my pjsip config?

Replace the + by 00 or remove it and set the call number to national

[…]