Read a variable on an AGI channel that was set in hangup handler

I receive a call, then call an AGI to control the call from the script.
I send the DIAL from the AGI script and set the hangup handler for the B leg to be executed on that channel.
Call is OK, then somebody hangs up.
Hangup handler is executed and I set a couple of variables, I see on the console ttose vars being populated. It is the RTCP stats for that channel:

Executing [s@BLegEndCall:4] NoOp(“PJSIP/C10270-T360-0000005e”, “RTCP STATS ssrc=1406574190;themssrc=1061584002;lp=0;rxjitter=0.000000;rxcount=159;txjitter=0.000057;txcount=0;rlp=0;rtt=0.000000”) in new stack

AGI is still running, I start reading those variables set in the hangup handler but get nothing, the vars are empty,
That is the issue, it seems that any var set in the hangup handler can not be read on the AGI script.

is this a bug or expected behavior?

is that is by design, is there any other way of getting those rtcp stats from my AGI?

The hangup handler for the B leg runs on the B leg channel, not the A leg one. You’d probably have to use SHARED variables, to access them on the A leg channel.

Thank you david… I tried shared vars too and also I have tried a hangup handler on the A channel as well. results are the same

Are you sure your AGI is not getting killed by the SIGHUP before it completes your stat task?

If you aren’t already, you might try setting AGISIGHUP=no on the channel before to make sure you aren’t running out of time. I ran into this issue when I wanted to call an AGI from a hangup handler, and it would be killed by a SIGHUP before it could complete its task, when Asterisk did its channel cleanup after hangup.

Or (better imho) enable a signal handler in your code. It’s there for a
reason :slight_smile:

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