Dialling PJSIP Channels only when available

Dear Community,

I’ve found and unexpected (For me) behavior in my dialplan,

Using this Wiki guide
3rd option dials Unavailable channels (Not replying SIP OPTIONS)
Something that is expected after reading the explanation a 2nd time

I was wondering how can i select an specific IP and dial it only if its available with the 4th adviced option of the guide:
exten => _9NXXNXXXXXX,1,Dial(PJSIP/${EXTEN:1}@mytrunk)

Should I replace @mytrunk with @IP?
Or how can i tell the Dialplan

I want @IP1, then @IP2, then @IP3

Any advice or idea is going to be appreciated
Warm Regards

I think you would need to read the status of the specific contact, prior to the Dial, as I’d expect Dial to use the status of the AOR, which will be the best of all its contacts’.

Unfortunately, as all too often the case, the documentation (PJSIP_CONTACT function) seems to beg more questions than it answers; how do you find the contact name, when all contacts are anonymous in pjsip.conf?

Checking before the DIal opens the race condition window wider, but there will always be one, so you must always cope with the actual Dial attempt finding it unreachable.

1 Like

Dear David,
Thanks for your reply,

If we compare Chan SIP with Chan pjsip when dialling some trunks, Chan sip didn’t dial them if the Trunk became unavailable/unresponsive only when using Dial app on the extensions.conf file.

You’re suggesting that, i should use other apps in order to create evaluations before dialling the trunk?
Like: If peer contact/options unresponsive, don’t dial

About PJSIP_CONTACT i will do some tests with
PJSIP_CONTACT(name,status) → Variable

Any other advice is surely welcome
Warm Regards

chan_sip didn’t allow multiple contacts, so the whole endpoint became unavailable when the only contact became unavailable. As I understand it, you have multiple contacts and you want to test the availability of a specific one, when another one is up, so the endpoint is up.

1 Like

I think we need to see the specific configuration along with “pjsip show contacts” along with version of Asterisk. Modern PJSIP should only dial a reachable contact, be it if the endpoint is dialed directly or using PJSIP_DIAL_CONTACTS.

1 Like

Thanks for your replies,

@david551

“As I understand it, you have multiple contacts and you want to test the availability of a specific one, when another one is up, so the endpoint is up”

Yes indeed, since calls are being sent whether SIP OPTIONS is replied or not with my Dial syntax ill have to create somehow validations of every IP … something that could “Clog” the Dialplan

@jcolp

“I think we need to see the specific configuration along with “pjsip show contacts” along with version of Asterisk. Modern PJSIP should only dial a reachable contact, be it if the endpoint is dialed directly or using PJSIP_DIAL_CONTACTS.”

Before sharing the “Logic” of Endpoints/Contacts, i would like to know if with the 4th example is feasible to dial contacts individually (Per IP) only if available,

Currently im using the 3rd example (Like stated in the first post)

PJSIP/mytrunk/sip:${EXTEN:1}@IP1
PJSIP/mytrunk/sip:${EXTEN:1}@IP2
PJSIP/mytrunk/sip:${EXTEN:1}@IP3
PJSIP/mytrunk/sip:${EXTEN:1}@IP4

This is the 4th example that should check if the Peer is alive.
PJSIP/${EXTEN:1}@mytrunk

How can i tell to the Dialplan,
Dial first this IP, then, Dial this second one without sending calls to unavailable (SIP OPTIONS) peers?

Should i try dev. a validation with PJSIP_Contact func?

Any idea will be greatly appreciated
Warm Regards

If you explicitly specify an IP address in the Dial line, then OPTIONS and qualify doesn’t apply. You’re using the endpoint configuration for the call, but not the AORs/contacts.

The contact has to be configured in pjsip.conf to be qualified, and it has to be dialed from the dialplan. You can’t specify the IP address in the dialplan.

If you want absolute control then individual endpoints with individual AORs are an option.

1 Like

Dear @jcolp

“If you explicitly specify an IP address in the Dial line, then OPTIONS and qualify doesn’t apply”

Understood… :confused:
Do you know if its possible to create multiple AORs assigned to a single Endpoint?

In order to use the following syntax:
PJSIP/${EXTEN:1}@mytrunk

If not, I will have to create multiple endpoints . . .
Or as adviced by @david551
Create a validation before sending the call.

Warm Regards

You can, but I’m not really sure why you’d do it over multiple contacts on the same AOR for this.

I’d just use separate endpoints, it also allows you to know from logging more easily which was chosen.

1 Like

Dear @jcolp
I’m trying to keep the configuration simplest as possible, avoiding duplicating Endpoints (6 times) per IP,
I’m kinda clearer now,

Working the dialplan a bit more or modifying pjsip.conf in order to dial peers per SIP AOR/Contact in the dialplan

Thanks a lot @jcolp and @david551
Any further idea is surely welcome, and greatly appreciated
Have a gr8 day
Warm Reggards

Hi There,

No further validation was required, When using ${PJSIP_DIAL_CONTACTS()} function inside Dial application the behavior works as expected, no calls are beign sent to non-reachable peers, instead, those will “fail” with CONGESTION, a re-routable “code” that can be captured in order to try to send another call.

exten => _X!,n,Dial(${PJSIP_DIAL_CONTACTS(${EndpointName},${AorName},${EXTEN})},60)
60s ring timeout

exten => _X!,n,GotoIf($[“${DIALSTATUS}”:“CONGESTION|CHANUNAVAIL”]?${Destination1}:${Destination2})

Hope this helps who reads this post
Warm Regards

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