Name

FastAGI() — Executes an AGI-compliant script across a network connection

Synopsis

FastAGI(agi://hostname[:port][/script],args)

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.

Tip

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)

See Also

AGI(), DeadAGI()

Get Asterisk: The Future of Telephony, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.