<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>FastAGI()</title><link rel="stylesheet" href="styles.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.69.1" /><link rel="start" href="index.html" title="Asterisk™: The Future of Telephony" /><link rel="up" href="asterisk-APP-B.html" title="Appendix B. Application Reference" /><link rel="prev" href="asterisk-APP-B-357.html" title="ExternalIVR()" /><link rel="next" href="asterisk-APP-B-77.html" title="Festival()" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">FastAGI()</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="asterisk-APP-B-357.html">Prev</a> </td><th width="60%" align="center">Appendix B. Application Reference</th><td width="20%" align="right"> <a accesskey="n" href="asterisk-APP-B-77.html">Next</a></td></tr></table><hr /></div><div class="refentry" lang="en" xml:lang="en"><a id="asterisk-APP-B-75"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>FastAGI() — Executes an AGI-compliant script across a network connection</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><a id="I_programlisting_tt2207"></a><pre class="programlisting">FastAGI(agi://<em class="replaceable"><code>hostname</code></em>[:<em class="replaceable"><code>port</code></em>][/<em class="replaceable"><code>script</code></em>],<em class="replaceable"><code>args</code></em>)</pre></div><div class="refsect1" lang="en" xml:lang="en"><a id="id4184308"></a><h2></h2><p><a id="I_indexterm_tt2208" class="indexterm"></a>Executes an AGI-compliant program across the network. This application is very similar to <code class="literal">AGI()</code>, 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).</p><p><code class="literal">FastAGI()</code> tries to connect directly to the running FastAGI program, which must already be listening for connections on the specified <em class="replaceable"><code>port</code></em> on the server specified by <em class="replaceable"><code>hostname</code></em>. If <em class="replaceable"><code>port</code></em> is not specified, it defaults to port 4573. If <em class="replaceable"><code>script</code></em> is specified, it is passed to the FastAGI program as the <code class="literal">agi_network_script</code> variable. The arguments specified by <em class="replaceable"><code>args</code></em> will be passed to the program.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><a id="asterisk-APP-B-NOTE-61"></a>Tip</h3><p>See <span class="emphasis"><em>agi/fastagi-test</em></span> in the Asterisk source directory for a sample FastAGI script. This should serve as a good roadmap for writing your own <span class="keep-together">FastAGI</span> programs.</p></div><p>Returns <code class="literal">-1</code> if the application requested a hangup, or <code class="literal">0</code> on a non-hangup exit.</p><a id="I_programlisting_tt2209"></a><pre class="programlisting">; connect to the sample fastagi-test program, which must already be running ; on the local machine exten => 123,1,Answer() <span class="strong"><strong>exten => 123,2,FastAGI(agi://localhost)</strong></span> ; 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() <span class="strong"><strong>exten => 124,2,FastAGI(agi://calvin:8000/testing,12345)</strong></span> </pre></div><div class="refsect1" lang="en" xml:lang="en"><a id="asterisk-APP-B-76"></a><h2>See Also</h2><p><a href="asterisk-APP-B-13.html" title="AGI()"><span class="refentrytitle">AGI()</span></a>, <a href="asterisk-APP-B-51.html" title="DeadAGI()"><span class="refentrytitle">DeadAGI()</span></a></p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="asterisk-APP-B-357.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="asterisk-APP-B.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="asterisk-APP-B-77.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ExternalIVR() </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Festival()</td></tr></table></div><div xmlns="" id="svn-footer"><hr /><p>You are reading <em>Asterisk: The Future of Telephony</em> (2nd Edition for Asterisk 1.4), by Jim van Meggelen, Jared Smith, and Leif Madsen.<br /> This work is licensed under the <a href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative Commons Attribution-Noncommercial-No Derivative Works License v3.0</a>.<br /> To submit comments, corrections, or other contributions to the text, please visit <a href="http://oreilly.com/catalog/9780596510480/">http://www.oreilly.com/</a>.</p></div></body></html>