[asterisk-users] AGI Script Returning 4

Steve Edwards asterisk.org at sedwards.com
Sat Jan 30 20:38:45 CST 2021


On 1/30/21 1:18 PM, Alexander Perkins wrote:

>> the PHP-AGI script fails after it is executed and simply returns 
>> 'returning 4'.

On Sat, 30 Jan 2021, Michal Rybarik wrote:

> I think this can happen by hanging up the call by one party, when SIGHUP 
> is sent to AGI script. PHP will exit on SIGHUP. It can be resolved by 
> initializing signal handler in PHP script (pcntl_signal) for SIGHUP and 
> doing nothing in it (return).

>From res_agi.c:

enum agi_result {
         AGI_RESULT_FAILURE = -1,
         AGI_RESULT_SUCCESS,
         AGI_RESULT_SUCCESS_FAST,
         AGI_RESULT_SUCCESS_ASYNC,
 	AGI_RESULT_NOTFOUND,
         AGI_RESULT_HANGUP,
};

so, AGI_RESULT_HANGUP == 4.

When Asterisk detects the hangup on the channel, it sends a SIGHUP to your 
AGI.

I always set a signal handler on SIGHUP and do what makes sense to my 
application: maybe some cleanup or syslog() before return() or exit(). 
Almost always exit().

-- 
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards       sedwards at sedwards.com      Voice: +1-760-468-3867 PST
             https://www.linkedin.com/in/steve-edwards-4244281



More information about the asterisk-users mailing list