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
Thanks a lot!