Exited non-zero error terminatiing AGI scripts

I am writing some custom AGI scripts that record audio from the enduser and then do some work on that audio afterwards.

The problem I’m facing is that, with no obvious regularity, sometimes when a user hangs up the phone after recording, the AGI script does not complete.

Usually, upon the enduser hanging up, the script will get a -1 in a Result and thus will be signaled that the user hung up, and will do the processing and cleanup work necessary.

However, sometimes the script seems to simply be killed by Asterisk.

Example of a successful run:
AGI Rx << RECORD FILE /home/asterisk/recording/data/i506W0CoqtPeoiTg wav “#” 300000 0 BEEP s=10000
– <SIP/100-081e7688> Playing ‘beep’ (language ‘en’)
AGI Tx >> 200 result=-1 (hangup) endpos=15520
AGI Rx << VERBOSE “RECORD_ROUTINE: recording good, 1.94 sec, saved to i506W0CoqtPeoiTg” 1
/etc/asterisk/agi/record.php|2:RECORD_ROUTINE: recording good, 1.94 sec, saved to i506W0CoqtPeoiTg
AGI Tx >> 200 result=1
– AGI Script /etc/asterisk/agi/record.php completed, returning 0

Example of a failed run:
AGI Rx << RECORD FILE /home/asterisk/recording/data/Xk83ni1UMZhQGqIh wav “#” 300000 0 BEEP s=10000
– <SIP/100-081e7688> Playing ‘beep’ (language ‘en’)
AGI Tx >> 200 result=-1 (hangup) endpos=15680
== Spawn extension (fxo-sip, 811, 2) exited non-zero on ‘SIP/100-081e7688’

As you can see, in the second run the VERBOSE command never gets executed, and obviously this means all the instructions post-recording are not being executed. It seems that Asterisk is simply killing the AGI script before it can run to completion.

I cannot find any obvious pattern. It seems completely random. Sometimes it works, sometimes it doesn’t. The fact that the post-recording code is not always running basically makes the script useless.

What can I do about this?


1 Like

figured it out, executing a Set command in my AGI script seems to have solved it.


Seems to be working properly now, will post if still having problems…

1 Like