FreePBX | Register | Issues | Wiki | Portal | Support

Hangup handler cannot fetch variable in IAX2 channel


#1

Hello all,

I’m using an IAX2 trunk to forward specific calls to a custom dialplan on a remote FreePBX.

The inbound DID is linked to the custom destination “ir_callflow”.

In the custom context, I set the hangup handler:

[ir_callflow]
exten => s,1,Answer
exten => s,n,Set(CHANNEL(hangup_handler_push)=hangup_handler_1,s,1(args))
exten => s,n,AGI(verycool_agi.php)

In the AGI Script I set the $unique_id variable, which should be available in the dialplan:

$agi->set_variable('unique_id', $unique_id);

In the hangup handler, I want to update a database record based on the ${unique_id} variable:\

[hangup_handler_1]
exten => s,1,NoOp(Stop inbound call...)
exten => s,n,Set(ODBC_ACTION_END(${unique_id})=)
exten => s,n,Set(ODBC_HANGUP(${unique_id})=)
exten => s,n,Hangup()

When the call is arriving from a standard SIP trunk (not via IAX2), I’m able to fetch the ${unique_id} variable:

-- SIP/sip_trunk_out-0000495c Internal Gosub(hangup_handler_1,s,1(args)) start
-- Executing [s@hangup_handler_1:1] NoOp("SIP/sip_trunk_out-0000495c", "Stop inbound call...") in new stack
-- Executing [s@hangup_handler_1:2] Set("SIP/sip_trunk_out-0000495c", "ODBC_ACTION_END(49405)=") in new stack
-- Executing [s@hangup_handler_1:3] Set("SIP/sip_trunk_out-0000495c", "ODBC_HANGUP(49405)=") in new stack

-> Here everything is working correctly, no issues!

When the call is arriving from the IAX2 trunk, the ${unique_id} is empty:

-- IAX2/iax2_fpbx1-3567 Internal Gosub(hangup_handler_1,s,1(args)) start
-- Executing [s@hangup_handler_1:1] NoOp("IAX2/iax2_ssw21-3567", "Stop inbound call...") in new stack
-- Executing [s@hangup_handler_1:2] Set("IAX2/iax2_ssw21-3567", "ODBC_ACTION_END()=") in new stack
-- Executing [s@hangup_handler_1:3] Set("IAX2/iax2_ssw21-3567", "ODBC_HANGUP()=") in new stack

Please help :slight_smile:

Thanks a lot!


#2

Forgot to mention: I’m using Asterisk 11.21.0 on Distro.


#3

Update:

Issue resolved thanks to Lorne!

He found out there were some echo statements in the AGI script that needed to be changed to $agi->verbose.

BR


(Lorne Gaetz) #4

This was really interesting. The AGI file was written in PHP, and was using echo statements in an attempt print debug info, notwithstanding the fact that this doesn’t work. The echo statements were just ignored when the Asterisk channel was chan_sip, but with IAX2 they somehow interfered with the actual phpagi methods. Changing echo to $agi->verbose so that debug output was written to the Asterisk console immediately fixed.