HANGUPCAUSE() Not Working In PJSIP For Failed Calls

Home » Asterisk Users » HANGUPCAUSE() Not Working In PJSIP For Failed Calls
Asterisk Users No Comments

Hi,

This is using Asterisk certified/13.21-cert2, FWIW.

I have a hangup handler on an outgoing SIP channel that grabs the SIP status like this:

NoOp(keys=${HANGUPCAUSE_KEYS()} sipmsg=${HANGUPCAUSE(${CHANNEL},tech)})

This works fine if the call connects to the other end but the caller for example hangs up while it’s still ringing:

NoOp(“PJSIP/custom-000000ab”, “keys=PJSIP/custom-000000ab sipmsg=SIP 180 Ringing”) in new stack

It also works fine if the call was answered:

NoOp(“PJSIP/custom-000000ad”, “keys=PJSIP/custom-000000ad,PJSIP/squiresvi-000000ac sipmsg=SIP 200 OK”) in new stack

But if the remote end returns an error status (eg 404) then I get nothing:

func_hangupcause.c:140 hangupcause_read: Unable to find information for channel PJSIP/custom-000000af
— Executing [sipdirect2@hangup_handlers_egress:6] NoOp(“PJSIP/custom-000000af”, “keys= sipmsg=”) in new stack

Any idea whether this is possible? It works fine in our old Asterisk 11
systems, but on Asterisk 13 with PJSIP I’m getting nowhere with it.

Cheers, Kingsley.