How to know if a PJSIP endpoint exists in Dialplan?

Hi, there is a WARNING that appears when dialling using ${PJSIP_DIAL_CONTACTS}:

pjsip/dialplan_functions.c:1085 pjsip_acf_dial_contacts_read: Specified endpoint 'thisTestEndpointDoesNotExist' was not found

A sample dialplan that can cause this is:

exten => _X.,1,NoOp(${CALLERID(num)} to ${EXTEN})
 same => n,Dial(${PJSIP_DIAL_CONTACTS(${EXTEN})},,Ttr)
 same => n,HangUp()

If there is no endpoint with the name of the called extension.

Is there a way to check in the dialplan if a PJSIP endpoint exists without issuing a NOTICE/WARNING/ERROR?

Something like

Set(myVar=${SHELL([ “x$(asterisk -rx ‘pjsip show aor thisTestEndpointDoesNotExist’|grep ^Unable)” = “x” ] && echo EXIST || echo NoSuchEP)})

should do what you want

SHELL is very expensive. It is also dangerous, so you have to disable safeties in asterisk.conf before you can use it.

There is the PJSIP_ENDPOINT dialplan function[1] which could be used to query for details about the endpoint. The DEVICE_STATE dialplan function[2] could also be used to check its state.

[1] PJSIP_ENDPOINT - Asterisk Documentation
[2] DEVICE_STATE - Asterisk Documentation

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