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.