System information

The default port number for a FastAGI connection is 4573. A different port number can
be appended to the URL after a colon. For example:
exten => 1234,1,AGI(agi://127.0.0.1:4574)
Just as with process-based AGI, arguments can be passed to a FastAGI application. To
do so, add them as additional arguments to the AGI() application, delimited by commas:
exten => 1234,1,AGI(agi://192.168.1.199,arg1,arg2,arg3)
FastAGI also supports the usage of SRV records if you provide a URL in the form of
hagi://. By using SRV records, you can list multiple hosts that Asterisk can attempt to
connect to for purposes of high availability and load balancing. In the following ex-
ample, to find a FastAGI server to connect to, Asterisk will do a DNS lookup for
_agi._tcp.shifteight.org:
exten => 1234,1,AGI(hagi://shifteight.org)
Pros of FastAGI
It’s more efficient than process-based AGI. Instead of spawning a process per call,
a FastAGI server can handle many calls.
DNS can be used to achieve high availability and load balancing among FastAGI
servers to further enhance scalability.
Cons of FastAGI
It is more complex to implement a FastAGI server than to implement a process-
based AGI application. However, implementing a TCP server is something that
has been done countless times before, so there are many examples available for
virtually any programming language.
Async AGI—AMI-Controlled AGI
Async AGI is a newer method of using AGI that was first introduced in Asterisk 1.6.0.
The purpose of async AGI is to allow an application that uses the Asterisk Manager
Interface (AMI) to asynchronously queue up AGI commands to be executed on a chan-
nel. This can be especially useful if you are already making extensive use of the AMI
and would like to take advantage of the same application to handle call control, as
opposed to writing a detailed Asterisk dialplan or developing a separate FastAGI server.
More information on the Asterisk Manager Interface can be found in
Chapter 20.
Async AGI is invoked by the AGI() application in the Asterisk dialplan. The argument
to AGI() should be async:agi, as shown in the following example:
exten => 1234,1,AGI(async:agi)
AGI Variants | 479