SIPPEER status analog for PJSIP

What function can I use for getting status of my sip trunk (working without registration) with enabled qualify_frequency in AOR section of pjsip configuration? Something that replace SIPPEER(trunk,status) for PJSIP.

https://wiki.asterisk.org/wiki/display/AST/Function_DEVICE_STATE

This function shows status NOT_INUSE on not working trunk and the same on working trunk. My not working trunk currently is not answer on any SIP Invite or Options requests. We have ‘qualify_frequency’ option, so now we send all the time OPTONS requests and not taking any response. CLI command ‘pjsip show contact/aor/endpoint’ show me that status of trunk is Unavail in status field, so I want to understand how can I handle this situation in dilplan, when network connectivity is working, but SIP service on remote end is dead.

You could try using the ChanIsAvail application in your dialplan:

https://wiki.asterisk.org/wiki/display/AST/Application_ChanIsAvail

I tried to use ChanIsAvail with chan_sip and qualify option on peer and Asterisk doesn’t set AVAILCHAN variable if peer is not available, with chan_pjsip and qualify_frequency option it always sets AVAILCHAN variable. Is it some kind of bug or it’s normal behavior?

That sounds like a bug to me, I’d suggest opening an issue on the tracker.

https://issues.asterisk.org/jira/secure/Dashboard.jspa

I found same issue on bugtracker:
https://issues.asterisk.org/jira/browse/ASTERISK-27399