[Asterisk-Users] oddness in AGI - a bug in AGI or my own insanity ?

Steven Critchfield critch at basesys.com
Wed Feb 26 06:58:22 MST 2003


On Wed, 2003-02-26 at 03:59, Florian Overkamp wrote:
> Alright, I'm debugging now. I've confirmed this problem occurs _only_ if a 
> previous command (like a WAIT FOR DIGIT) did _not_ get any digits.
> 
> Okay - spotted. The problem lays in a combination of my own AGI code and 
> the way Asterisk appears to handle commands.
> 
> There was a bug in my code which caused some warnings to be thrown at 
> Asterisk. Asterisk could not find these in its command list (ofcourse) and 
> bugs on this. However, since it was unexpected output, there is also no 
> expected input from Asterisk as far as the AGI script is concerned. Which 
> in turn causes many other commands to fail.

Warnings should be thrown to STDERR. This ges the data out, but doesn't 
send it to AGI.

> It seems a bit weird that AGI allows commands to overlap, i.e. STREAM FILE 
> can be followed by other commands. Current behaviour is that these commands 
> are honoured, even though there was no result for the STREAM FILE yet. The 
> STREAM FILE continues to play, even though my script now expects it to be 
> finished and starts throwing other commands at Asterisk.
> 
> I think it would be better if commands in AGI were not honoured at all 
> untill the current command loop has finished in a normal fashion (either by 
> timeout or user input).

Since you are using STDIN and STDOUT which are buffered by the OS, AGI
doesn't accept any new commands while the current command is running,
you just have queued it up for when AGI is ready. Kind of like typing
ahead in a shell while it is busy on a command. The command completes
and the shell goes to reading from STDIN till it finds a return and
starts processing again.

So far, there has been few to no problems getting scripts to work when
you control your STDOUT output. If you are using perl, and you have
errors being generated outside of your control, your may want to
consider using select to try and reroute the warnings out to STDERR, and
then specify STDOUT for your commands.

-- 
Steven Critchfield <critch at basesys.com>




More information about the asterisk-users mailing list