[Asterisk-Users] Multiple AGI Issues

Freddi Hansen fh at danovation.dk
Tue Feb 14 16:36:00 MST 2006


>
>
>
>
> To:
> "Asterisk Users Mailing List - Non-Commercial Discussion" 
> <asterisk-users at lists.digium.com>
>
>
> I've got several issues with AGI/FastAGI
>
> 1. When an AGI script sends a command to Asterisk via stdin, why does Asterisk block and not return a result until the command is complete? Specifically, the dial command. If I send a Dial command to Asterisk, I don't get a return result until AFTER the call is HUNG UP. Not when it's ringing, not when the call is connected, but when it's DISCONNECTED. Why is that? How are you supposed to use commands like CHANNEL STATUS if you have to wait until the call is hung up, to check it's status?
>
> 2. Why do AGI scripts stay in memory until a call is complete? Is there any way to have the script terminate when a call is connected? With this scenario, you have a script for every single call in place, and that's really bad from a system resource perspective.
>
> 3. Seems that no scripting language is up to the task of FastAGI. Perl's threads aren't thread-safe with DBI and Python's aren't completely thread safe either. Don't know about Ruby, and I ain't no C programmer. What have people implemented? I also don't like the threading approach, because if something goes wrong with the script/server, you lose the ability to place ANY calls.
>
> Doug
>
>   
Hi,
If you want to have a speedy system that doesn't steal to many system 
resources then you have to use FastAGI. That being said you have to 
program your FastAGI server so it's completely event driven. The way to 
deal with f.ex. the dial command can be to let the FastAGI set a 
dialplan variable and then send the control back to the dialplan which 
then can execute the dial command that your FastAGI did prepare. I 
prefer to use perl for most AGI/FastAGI solutions, the servers are 
started out of inittab so no forking overhead during call handling. I do 
normally build FastAGI servers around 'select' so the process is either 
working or waiting on requests. I know you will say that means that no 
FastAGI request are served while I wait for database responses. The 
workaround is to start more than one copy of your FastAGI server on 
different ports. Create a global variable in your dialplan ,  increment  
on each call  - do a mod(4)  if you have  4 servers  so you can 
interleave the FastAGI requests between the servers.  If you need 
persistent data for you 'after call' process then use you DB system.
Let your FastAGI server write a dialplan status variable so you can 
retry another FastAGI server in case first one fails.
It's not difficult to get 100+ call setups per second with this approach.
b.r.
Freddi

   




More information about the asterisk-users mailing list