Cannot contact sip trunk

Bonjour,

I have a SIP trunk that I’ve been freshly delivered…. But I’m struggling to connect my asterisk on it…
I’ve read that I should create a dedicated endpoint with and outbound-route to enable my communication to go through another distant sip server.
So I tried that naming my endpoint with the dedicated number (I tried to hide my credentials in the sample but I obviously wrote them in my conf).
/etc/astersik/pjsip.conf :

**[general]**

type=global

endpoint_identifier_order = header,auth_username

**[transport-udp]**

type=transport

protocol=udp ;udp,tcp,tls,ws,wss,flow

bind=0.0.0.0:5060

local_net=************

local_net=**************

local_net=XXX.XXX.XXX.XXX/XX

external_media_address=XXX.XXX.XXX.XXX/XX

external_signaling_address=XXX.XXX.XXX.XXX/XX

**[594594140950]**

type=auth

auth_type=userpass

username=*************

password=*************

**[594594140950]**

type=aor

max_contacts=1

remove_existing=yes

contact=sip:...........eu

**[594594140950]**

type=registration

server_uri=sip:………...

client_uri=sip::………...

contact_user=:………

outbound_auth=594594140950

transport=transport-udp

**[594594140950]**

type=outbound-route

endpoint=594594140950

The dial plan is setted like that in /etc/asterisk/extensions.conf. We want to differentiate number starting by O or + to route them on the trunk sip number :

**[general]**

exten => _X.,1,NoOp(General context call to ${EXTEN})

same => n,Dial(PJSIP/${EXTEN})

same => n,Hangup()

**[594594140950]**

exten => _X.,1,NoOp(Received call from trunk to ${EXTEN})

same => n,Dial(PJSIP/vromain)

same => n,Hangup()

**[assistance]**

exten => _X.,1,NoOp(Typed call to ${EXTEN})

same => n,Set(EXTENSION=${EXTEN}) ; Stocker l'extension dans une variable de canal

same => n,GotoIf($["${EXTENSION:0:1}" = "0" | "${EXTENSION:0:1}" = "+" ]?external,1)

same => n,Goto(internal,${EXTENSION},1)

same => n,Hangup()

exten => external,1,NoOp(Number is long enough: ${EXTENSION} ! Processing external call...)

same => n,Dial(PJSIP/594594140950/${EXTENSION})

same => n,Hangup()

exten => internal,1,NoOp(Number is short : ${EXTENSION}. Processing internal call...)

same => n,Goto(general,${EXTENSION},1)

same => n,Hangup()

exten => contact,1,NoOp(Initiated internal call to ${EXTEN})

same => n,Dial(PJSIP/contact)

same => n,Hangup()

exten => jandrena,1,NoOp(Initiated internal call to ${EXTEN})

same => n,Dial(PJSIP/jandrena)

same => n,Hangup()

exten => vromain,1,NoOp(Initiated internal call to ${EXTEN})

same => n,Dial(PJSIP/vromain)

same => n,Hangup()

When I try to call an external number it say :

**--** Executing [0594272000@assistance:1] **NoOp**("**PJSIP/vromain-00000001**", "**Typed call to 0594272000**") in new stack

**--** Executing [0594272000@assistance:2] **Set**("**PJSIP/vromain-00000001**", "**EXTENSION=0594272000**") in new stack

**--** Executing [0594272000@assistance:3] **GotoIf**("**PJSIP/vromain-00000001**", "**1?external,1**") in new stack

**--** Goto (assistance,external,1)

**--** Executing [external@assistance:1] **NoOp**("**PJSIP/vromain-00000001**", "**Number is long enough: 0594272000 ! Processing external call...**") in new stack

**--** Executing [external@assistance:2] **Dial**("**PJSIP/vromain-00000001**", "**PJSIP/594594140950/0594272000**") in new stack

[Sep 3 21:18:40] **ERROR**[46730]: **res_pjsip.c**:**993** **ast_sip_create_dialog_uac**: Endpoint '594594140950': Could not create dialog to invalid URI '0594272000'. Is endpoint registered and reachable?

[Sep 3 21:18:40] **ERROR**[46730]: **chan_pjsip.c**:**2698** **request**: Failed to create outgoing session to endpoint '594594140950'

[Sep 3 21:18:40] **NOTICE**[46877][C-00000002]: **app_dial.c**:**2766** **dial_exec_full**: Unable to create channel of type 'PJSIP' (cause 3 - No route to destination)

**==** Everyone is busy/congested at this time (1:0/0/1)

**--** Executing [external@assistance:3] **Hangup**("**PJSIP/vromain-00000001**", "") in new stack

**==** Spawn extension (assistance, external, 3) exited non-zero on 'PJSIP/vromain-00000001'

And if I use the full number like +594594123456 it say :

NOTICE[46730]: res_pjsip_session.c:4041 new_invite: vromain: Call (UDP:10.10.10.249:55071) to extension ‘+594594272200’ rejected because extension not found in context ‘assistance’.

Which I don’t understand because I thaught that it would act the same as when you use 0594 as it both go to the external extension.

Can someone help me to understand please ?

This is not valid for what you want to do. It should be[1]:

same => n,Dial(PJSIP/${EXTENSION}@594594140950)

[1] Dialing PJSIP Channels - Asterisk Documentation

if I understand correctly, we now use the context and not an extension. But why we have two different behavior regarding if the extension start by 0 or + ?

You cut off the debug after a certain amount, but you don’t have dialplan to handle if it starts with “+” so it wouldn’t work.

As for context and not an extension, I don’t know what you mean. A Dial string is completely up to each channel driver how it looks and works. In the case of PJSIP it was made so that it was extension@endpoint

These are invalid; they must be addresses, not networks.

It is set on the public address of my router but do you mean that I should take out the CIDR mask that I added at the end ?

I’ve wrote it like that in the example but I didn’t put the CIDR in the conf sorry for the misleading information

isn’t it what I do with same => n,GotoIf($[“${EXTENSION:0:1}” = “0” | “${EXTENSION:0:1}” = “+” ]?external,1)
?

You have an aor, auth and registration defined for 594594140950 but you don’t have an endpoint defined. There’s also no such pjsip object type named ‘outbound-route’.

https://docs.asterisk.org/Configuration/Channel-Drivers/SIP/Configuring-res_pjsip/

could you please explain me the syntaxe and what my syntaxes would do so I could understand better

This matches dialed numbers starting with a number. You would need to write additional dialplan[1] to handle the case of starting with a +. Dialplan is fundamental, so I would suggest reading and experimenting with it to get an understanding.

[1] Contexts, Extensions, and Priorities - Asterisk Documentation

can I have multiple priority 1 on my context ?

I now have that :
[ Context ‘assistance’ created by ‘pbx_config’ ]
‘_+X.’ => 1. NoOp(External number ! Typed call to ${EXTEN}) [extensions.conf:882]
2. Set(EXTENSION=${EXTEN}) [extensions.conf:883]
3. Dial(PJSIP/${EXTENSION}@+594594140950) [extensions.conf:884]

‘_[0-9a-zA-Z]+’ => 1. NoOp(Internal number ! Typed call to ${EXTEN}) [extensions.conf:878]
2. Dial(PJSIP/${EXTEN}) [extensions.conf:879]
3. Hangup() [extensions.conf:880]

-= 2 extensions (6 priorities) in 1 context. =-

On Saturday 07 September 2024 at 14:03:32, engineirie via Asterisk Community
wrote:

can I have multiple priority 1 on my context ?

a) yes, but it makes no sense, and only one of them will get executed
(probably the first or the last, but I have no idea which)

b) no, Asterisk will ignore all except one, so although you won’t get an
error, only one has any effect so the others are pointless

c) why do you want to?

Antony.


A user interface is like a joke.
If you have to explain it, it means it doesn’t work.

                                               Please reply to the list;
                                                     please *don't* CC me.

Yes. That’s the normal case. However, I don’t think that is the question you are trying to ask, and I have a feeling that your second pattern is assuming Posix regular expression syntax, whereas the the +, after the ] will actually be matched literally.

1 Like

I didn’t copy/paste it well sorry. It look like that :

[general]

type=global

endpoint_identifier_order = header,auth_username

[transport-udp]

type=transport

protocol=udp ;udp,tcp,tls,ws,wss,flow

bind=0.0.0.0:5060

local_net=192.168.17.248/29

local_net=192.255.255.248/29

local_net=10.10.10.248/29

external_media_address=46.4.42.59

external_signaling_address=46.4.42.59

[registrar]

type=registrar

transport=transport-udp

[user_registration](!)

type=registration

server_uri=sip:192.255.255.251

transport=transport-udp

[assistance_endpoint](!)

type=endpoint

transport=transport-udp

context=assistance

disallow=all

allow=ulaw,alaw,g722,gsm

rtp_symmetric=yes

force_rport=yes

rewrite_contact=yes

identify_by=auth_username

outbound_proxy=sip.telcoz.eu

[assistance_auth](!)

type=auth

auth_type=userpass

[assistance_aor](!)

type=aor

max_contacts=1

remove_existing=yes

[commercial_endpoint](!)

type=endpoint

transport=transport-udp

context=commercial

disallow=all

allow=ulaw,alaw,g722,gsm

rtp_symmetric=yes

force_rport=yes

rewrite_contact=yes

identify_by=auth_username

outbound_proxy=sip.telcoz.eu

[commercial_auth](!)

type=auth

auth_type=userpass

[commercial_aor](!)

type=aor

max_contacts=1

remove_existing=yes

;;;;;;;;;;;;;;;;;;;;

;DEFINITION MANUELLE DES UTILISATEURS

;;;;;;;;;;;;;;;;;;;;

[vromain](assistance_endpoint)

auth=vromain

aors=vromain

[vromain](assistance_auth)

username=vromain

password=test

[vromain](assistance_aor)

contact=sip:vromain@192.168.2.34:5060

[vromain](user_registration)

client_uri=sip:vromain@192.255.255.251

contact_user=vromain

outbound_auth=vromain

[jandrena](assistance_endpoint)

auth=jandrena

aors=jandrena

[jandrena](assistance_auth)

username=jandrena

password=test

[jandrena](assistance_aor)

contact=sip:jandrena@192.168.2.34:5060

[jandrena](user_registration)

client_uri=sip:jandrena@192.255.255.251

contact_user=jandrena

outbound_auth=jandrena

[contact](commercial_endpoint)

auth=contact

aors=contact

[contact](commercial_auth)

username=contact

password=test

[contact](commercial_aor)

contact=sip:contact@192.168.2.34:5060

[contact](user_registration)

client_uri=sip:contact@192.255.255.251

contact_user=contact

outbound_auth=contact

[+594594140950]

type=outbound-proxy

proxy=sip.telcoz.eu:5060

transport=transport-udp

send_dns_srv=yes

[+594594140950]

type=endpoint

transport=transport-udp

context=594594140950

disallow=all

allow=ulaw,alaw,g722,gsm

rtp_symmetric=yes

force_rport=yes

rewrite_contact=yes

identify_by=auth_username

aors=+594594140950

auth=+594594140950

outbound_auth=+594594140950

[+594594140950]

type=auth

auth_type=userpass

username=*****************

password=*****************

[+594594140950]

type=aor

max_contacts=1

remove_existing=yes

contact=sip:engineirie97300@sip.telcoz.eu

[+594594140950]

type=registration

server_uri=sip:sip.telcoz.eu

client_uri=sip:engineirie97300@sip.telcoz.eu

contact_user=+594594140950

outbound_auth=+594594140950

transport=transport-udp

[+594594140950]

type=outbound-route

endpoint=+594594140950

outbound_auth=+594594140950

outbound_proxy=sip:sip.telcoz.eu

transport=transport-udp

[+594594140950]

type=identify

endpoint=+594594140950

match=[sip.telcoz.eu](http://sip.telcoz.eu)

but the logs still saying :

<--- Received SIP request (1049 bytes) from UDP:10.10.10.249:57318 --->

INVITE sip:+594594272200@192.255.255.251;transport=UDP SIP/2.0

Via: SIP/2.0/UDP 10.10.10.249:57318;branch=z9hG4bK-524287-1---33ae86333fc36b61;rport

Max-Forwards: 70

Contact: 

To: 

From: ;tag=71c95a17

Call-ID: D8hr1xSWV46CMgnQhSirWA..

CSeq: 1 INVITE

Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE

Content-Type: application/sdp

Supported: replaces, norefersub, extended-refer, timer, sec-agree, outbound, path, X-cisco-serviceuri

User-Agent: Z 5.5.15 v2.10.19.5

Allow-Events: presence, kpml, talk, as-feature-event

Content-Length: 341

v=0

o=Z 0 623695994 IN IP4 10.10.10.249

s=Z

c=IN IP4 10.10.10.249

t=0 0

m=audio 57229 RTP/AVP 106 9 98 101 0 8 3

a=rtpmap:106 opus/48000/2

a=fmtp:106 sprop-maxcapturerate=16000; minptime=20; useinbandfec=1

a=rtpmap:98 telephone-event/48000

a=fmtp:98 0-16

a=rtpmap:101 telephone-event/8000

a=fmtp:101 0-16

a=sendrecv

a=rtcp-mux

<--- Transmitting SIP response (519 bytes) to UDP:10.10.10.249:57318 --->

SIP/2.0 401 Unauthorized

Via: SIP/2.0/UDP 10.10.10.249:57318;rport=57318;received=10.10.10.249;branch=z9hG4bK-524287-1---33ae86333fc36b61

Call-ID: D8hr1xSWV46CMgnQhSirWA..

From: ;tag=71c95a17

To: ;tag=z9hG4bK-524287-1---33ae86333fc36b61

CSeq: 1 INVITE

WWW-Authenticate: Digest realm="asterisk",nonce="1725979614/0a5b91e1489c94fd52bd679974ac2c71",opaque="35d63750228b1d14",algorithm=MD5,qop="auth"

Server: Asterisk PBX 20.9.2

Content-Length: 0

<--- Received SIP request (379 bytes) from UDP:10.10.10.249:57318 --->

ACK sip:+594594272200@192.255.255.251;transport=UDP SIP/2.0

Via: SIP/2.0/UDP 10.10.10.249:57318;branch=z9hG4bK-524287-1---33ae86333fc36b61;rport

Max-Forwards: 70

To: ;tag=z9hG4bK-524287-1---33ae86333fc36b61

From: ;tag=71c95a17

Call-ID: D8hr1xSWV46CMgnQhSirWA..

CSeq: 1 ACK

Content-Length: 0

<--- Received SIP request (1361 bytes) from UDP:10.10.10.249:57318 --->

INVITE sip:+594594272200@192.255.255.251;transport=UDP SIP/2.0

Via: SIP/2.0/UDP 10.10.10.249:57318;branch=z9hG4bK-524287-1---f8ba10d86dbb268d;rport

Max-Forwards: 70

Contact: 

To: 

From: ;tag=71c95a17

Call-ID: D8hr1xSWV46CMgnQhSirWA..

CSeq: 2 INVITE

Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE

Content-Type: application/sdp

Supported: replaces, norefersub, extended-refer, timer, sec-agree, outbound, path, X-cisco-serviceuri

User-Agent: Z 5.5.15 v2.10.19.5

Authorization: Digest username="vromain",realm="asterisk",nonce="1725979614/0a5b91e1489c94fd52bd679974ac2c71",uri="sip:+594594272200@192.255.255.251;transport=UDP",response="bce567b3dc1aa40353a98a7ee55e5557",cnonce="ebc1817b6b23ffc8be3ee1787ac6bb31",nc=00000001,qop=auth,algorithm=MD5,opaque="35d63750228b1d14"

Allow-Events: presence, kpml, talk, as-feature-event

Content-Length: 341

v=0

o=Z 0 623695994 IN IP4 10.10.10.249

s=Z

c=IN IP4 10.10.10.249

t=0 0

m=audio 57229 RTP/AVP 106 9 98 101 0 8 3

a=rtpmap:106 opus/48000/2

a=fmtp:106 sprop-maxcapturerate=16000; minptime=20; useinbandfec=1

a=rtpmap:98 telephone-event/48000

a=fmtp:98 0-16

a=rtpmap:101 telephone-event/8000

a=fmtp:101 0-16

a=sendrecv

a=rtcp-mux

<--- Transmitting SIP response (327 bytes) to UDP:10.10.10.249:57318 --->

SIP/2.0 100 Trying

Via: SIP/2.0/UDP 10.10.10.249:57318;rport=57318;received=10.10.10.249;branch=z9hG4bK-524287-1---f8ba10d86dbb268d

Call-ID: D8hr1xSWV46CMgnQhSirWA..

From: ;tag=71c95a17

To: 

CSeq: 2 INVITE

Server: Asterisk PBX 20.9.2

Content-Length: 0

-- Executing [+594594272200@assistance:1] NoOp("PJSIP/vromain-00000001", "External number ! Typed call to +594594272200") in new stack

-- Executing [+594594272200@assistance:2] Set("PJSIP/vromain-00000001", "EXTENSION=+594594272200") in new stack

-- Executing [+594594272200@assistance:3] Dial("PJSIP/vromain-00000001", "PJSIP/+594594140950/+594594272200") in new stack

[Sep 10 14:46:55] ERROR[76411]: res_pjsip.c:993 ast_sip_create_dialog_uac: Endpoint '+594594140950': Could not create dialog to invalid URI '+594594272200'. Is endpoint registered and reachable?

[Sep 10 14:46:55] ERROR[76411]: chan_pjsip.c:2698 request: Failed to create outgoing session to endpoint '+594594140950'

[Sep 10 14:46:55] NOTICE[76483][C-00000002]: app_dial.c:2766 dial_exec_full: Unable to create channel of type 'PJSIP' (cause 3 - No route to destination)

== Everyone is busy/congested at this time (1:0/0/1)

-- Auto fallthrough, channel 'PJSIP/vromain-00000001' status is 'CHANUNAVAIL'

<--- Transmitting SIP response (404 bytes) to UDP:10.10.10.249:57318 --->

SIP/2.0 503 Service Unavailable

Via: SIP/2.0/UDP 10.10.10.249:57318;rport=57318;received=10.10.10.249;branch=z9hG4bK-524287-1---f8ba10d86dbb268d

Call-ID: D8hr1xSWV46CMgnQhSirWA..

From: ;tag=71c95a17

To: ;tag=955e1992-a02a-47ef-837e-a279d98a8cde

CSeq: 2 INVITE

Server: Asterisk PBX 20.9.2

Reason: Q.850;cause=3

Content-Length: 0

<--- Received SIP request (380 bytes) from UDP:10.10.10.249:57318 --->

ACK sip:+594594272200@192.255.255.251;transport=UDP SIP/2.0

Via: SIP/2.0/UDP 10.10.10.249:57318;branch=z9hG4bK-524287-1---f8ba10d86dbb268d;rport

Max-Forwards: 70

To: ;tag=955e1992-a02a-47ef-837e-a279d98a8cde

From: ;tag=71c95a17

Call-ID: D8hr1xSWV46CMgnQhSirWA..

CSeq: 2 ACK

Content-Length: 0

Please mark up your logs as preformatted text

CAN You me tell the way to do it please ?

If you mean the markup, select the text, than click the </> button, or precede and follow the text by a sequence of three back ticks.

1 Like