FastAGI() — Executes an AGI-compliant script across a network connection
Executes an AGI-compliant program across the network. This
application is very similar to AGI()
,
except that it calls a specially written FastAGI script across a network
connection. The main purposes for using FastAGI are to offload
CPU-intensive AGI scripts to remote servers and to help reduce AGI
script startup times (the FastAGI program is already running before
Asterisk connects to it).
FastAGI()
tries to connect
directly to the running FastAGI program, which must already be listening
for connections on the specified port
on the
server specified by hostname
. If
port
is not specified, it defaults to port
4573. If script
is specified, it is passed to
the FastAGI program as the agi_network_script
variable. The arguments
specified by args
will be passed to the
program.
See agi/fastagi-test in the Asterisk source directory for a sample FastAGI script. This should serve as a good roadmap for writing your own FastAGI programs.
Returns -1
if the application
requested a hangup, or 0
on a
non-hangup exit.
; connect to the sample fastagi-test program, which must already be running ; on the local machine exten => 123,1,Answer() exten => 123,2,FastAGI(agi://localhost) ; connect to a FastAGI script on a host named "calvin" on port 8000, and pass along ; a script name of "testing", with the argument "12345" exten => 124,1,Answer() exten => 124,2,FastAGI(agi://calvin:8000/testing,12345)