O'Reilly logo

Asterisk: The Future of Telephony by Leif Madsen, Jared Smith, Jim Van Meggelen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required