B.41. FastAGI()

Calls an AGI-compliant application over a network connection.
FastAGI(agi://hostname[:port][/script],arguments)
(Similar to AGI(), DeadAGI(), EAGI())
Runs an Asterisk Gateway Interface compliant program on the current channel, but calls the application from another host on the network. The intent is to help distribute the load of processor-intensive AGI scripts or programs to remote servers and reduce start-up latency of those programs (a FastAGI script can be started before it is actually needed, much like a FastCGI script on a web server).
FastAGI() attempts to connect directly to a running FastAGI program listening for connections on the specified port on the server hostname. The default port is 4573 if it is not specified. If script is defined, it is used to populate the variable agi_network_script and passed to the FastAGI program. The arguments are also passed to the program.
A sample FastAGI script can be found at agi/fastagi-test. Use this is a starting point for writing your own FastAGI applications.
Returns -1, if the application ends and requests a hang-up; returns 0 if it ends without requesting a hang-up.
; Connect to the sample FastAGI program "fastagi-test",
; which must nevertheless be running on the local machine:
exten => 123,1,Answer()
exten => 123,n,FastAGI(agi://localhost/fastagi-test)

; Connect to the FastAGI script "test" on the host "testbox"
; at port 9000 and pass parameter "123":
exten => 124,1,Answer()
exten => 124,n,FastAGI(agi://testbox:9000/test,123)