[asterisk-users] Re : Controlling calls

Steve Edwards asterisk.org at sedwards.com
Sun Jun 6 11:25:49 CDT 2010


Un-top-posting...

> On Sat, 5 Jun 2010, Adil Zaaraoui wrote:
> 
> > I want to write an AGI script doing this:
> >
> > 1-user call a number.
> > 2-asterisk call the agi script
> > 3-the script dial the peer
> > 4-if the call is answered, let the call up for 1min
> > 5-then the script hangs up the channel.

On Sun, 6 Jun 2010, Adil Zaaraoui wrote:

> 1- yes i need to call my agi script; because i have to process some 
> tasks with my DBMS on the caller.

Can you set an absolute timeout either in your script or before you call 
your script?

> 2- yes it is my first script,  "While very simple, the AGI protocol is 
> easy to violate" i did not get your meaning.

The AGI protocol is implemented by issuing requests and receiving 
responses via STDOUT and STDIN respectively. (FastAGI uses network 
sockets.)

Most programmer's first "fail" is not reading the AGI environment from 
STDIN first. Next, they fail to realize that for every request, they must 
read the response. Lastly, they try to debug their AGI by reading 
something from STDIN or writing something to STDOUT, not remembering that 
STDIN and STDOUT are "connected" to Asterisk, not their console.

I always recommend that programmers use an existing library rather than 
developing their own. The chance of success is much higher.

Most AGI problems I have seen (mine and others) can be resolved by 
understanding the above and enabling AGI debugging on the console and 
observing the output.

> So do you have a perfect solution?

There are no perfect solutions :)

Setting an absolute timeout sounds pretty good to me. It's simple and 
obvious.

You may consider setting a channel variable with the peer dial string in 
your AGI and keeping the "dial" command in the dialplan. It seems like a 
better approach to me, but then I've only had 1 cup of tea this morning 
and can't explain why coherently.

-- 
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards       sedwards at sedwards.com      Voice: +1-760-468-3867 PST
Newline                                              Fax: +1-760-731-3000


More information about the asterisk-users mailing list