Can't get PJSIP_CONTACT function to work

Trying to get the status of an endpoint using pjsip, but so far not having any luck.

If I use 'pjsip show contact ’ it returns ‘Status’ and ‘RTT(ms)’

From what I understand PJSIP_CONTACT function should be able to return this data, however I am not able to find any ‘objects’ to work for me, or found any relevant examples online anywhere.

NoOp(Test: ${PJSIP_CONTACT(trunk/sip:12.12.12.11:5060,status)}) doesn’t work
NoOp(Test: ${PJSIP_CONTACT(trunk/sip:12.12.12.11:5060,user_agent)}) saw this example somewhere, doesn’t work
NoOp(Test: ${PJSIP_CONTACT(trunk/sip:12.12.12.11:5060,rtt)}) doesn’t work

pjsip show contact trunk/sip:12.12.12.11:5060 returns:
Contact: trunk/sip:12.12.12.11:5060 88c424b1fa Avail 4.30

Any suggestions or alternate function to get this information would be helpful.

Thanks in advance.

The identifier you are using in the CLI is not the identifier that can be used to query for it using the PJSIP_CONTACT dialplan function. It used to be, but some Contact URIs are quite large. You can use the PJSIP_AOR dialplan function to get the actual value. We should be able to allow both though so please file an issue on the issue tracker[1] for it.

[1] https://issues.asterisk.org/jira

1 Like

Thank you for the clarification, I was able to get what I needed using this workaround:

${PJSIP_CONTACT(${PJSIP_AOR(trunk,contact)},rtt)})
${PJSIP_CONTACT(${PJSIP_AOR(trunk,contact)},status)})

I will file an issue as you requested. Thanks!

1 Like