PJSIP Endpoint Status Detect Before dailing to Endpoint

Hello All,

I have two endpoints 4000 - 4001 and my dailplan is:
exten => 4000,1,Dial(PJSIP/4000&PJSIP/4001)

if 4001 not register I have seen below log.

 res_pjsip.c:2513 ast_sip_create_dialog_uac: Could not create dialog to endpoint '4001'as URI '4001' is not valid
 chan_pjsip.c:1862 request: Failed to create outgoing session to endpoint '4001'

I want to detect endpoints registration status before call and I want to bypass this error log by change my dial plan:

if 4001 register Dail(PJSIP/4000&PJSIP/4001)

Could you give imformation about. how can I do this.
Thanks for your replies.

I’ll just ask… why?

While it’s possible to do this (using the DEVICE_STATE dialplan function) it’s still possible for the situation to occur if the endpoint becomes available after you do the check and it also adds additional logic and complication to your dialplan.

Thank for your reply. I got it.