FastAGI

itjumper

Joined
Jul 22, 2008
Messages
81
Likes
0
Points
0
#1
anyone has any idea how to set up an agi server ??
 

haamed

Joined
Jul 23, 2007
Messages
251
Likes
0
Points
0
#2
Hy my friend,
before setting up Agi server, you should choose your language programming,
you can use agi commnd on many manguages like C,JAVA,PHP,Perl,Rubby & ...
I prefer PHP for small programs and JAVA for huge ones,


Good jobB)
 

itjumper

Joined
Jul 22, 2008
Messages
81
Likes
0
Points
0
#3
I used php and found phpagi-fastagi. However, input/output from stdin and stdout are not passed. Looking at phpagi-fastagi, shouldn't the socket be passed to the NEW AGI (3rd parameter in the constructor)?? But where is the socket defined in phpagi-fastagi??
 

drclue

Joined
Sep 1, 2009
Messages
9
Likes
0
Points
0
#4
After having looked at various FastAGI offerings , I had decided I really did not care for any of them.

Being as I can just as easily create daemons in C++ or PHP, I had a choice to make.
For ease of development I elected to create a generic PHP daemon that would
allow me to dynamically load PHP scripts via the dial plan.

This makes development really easy as I can simply edit,save and dial, vs. any kind of
compiling or restarting after an edit to a particular PHP script.

When a script is called it is passed a reference to a PHP object containing all the
information passed by asterisk as well as interfaces to both AGI and AMI resources, and
soon a MySql reference as well so a script has everything it needs in a nice thin interface.

I've posted the code for it at google projects. http://code.google.com/p/fastagi-php-drclue/

There is also a WIKI with documentation on installation, class methods and such along with
a couple of example scripts.

The FastAGI.php script even has a command line option that will generate the init.d
script so that the FastAGI.php daemon will start at boot.


Enjoy!!!
 

rafael

Joined
May 14, 2007
Messages
1,454
Likes
1
Points
0
#5
nice dr. clue :D

Thanks a lot for sharing your code :D
 

haamed

Joined
Jul 23, 2007
Messages
251
Likes
0
Points
0
#6
Thanks drclue,
that was nice,
I hope we can more references in this forum,

Thanks again:kiss:
 

itjumper

Joined
Jul 22, 2008
Messages
81
Likes
0
Points
0
#7
Excellent. Got my fastagi server running after fixing one bug in class.daemon.inc

I have a question regarding calling phpagi inside a Fastagi script.

I have 2 asterisk servers. Server A handles incoming call, server B handles some other phone lines.

my senerio is

1. caller calls into server A
2. server A invokes a fastagi script on serevr B, passing some info to it
3. server B will then make a phone call using the phone lines attached to itself (server B)
4. server B will pass the result back to server A
5. server A will then continue with the dial plan

Can anyone tell me if I can use phpagi inside a Fastagi script? It seems to hang with the "New" instance.
 

drclue

Joined
Sep 1, 2009
Messages
9
Likes
0
Points
0
#8
Howdy itjumper

Firstly , if there was an error that you corrected , please let me know
so that I can fix it in the main code for everyone.


As to contacting the instance of asterisk on server B,
from the FastAGI plugin ,I guess I would for a down and dirty fix, issue
a an AMI logout command.

$oDaemon->AMIcommand("logout")

Then I would adjust the $oDaemon member variables $szAMIusername,$szAMIsecret,
$iAMIserverPort, and $iAMIserverHost as needed and call $oDaemon->AMIlogin()
to connect to server B's AMI interface to place the call.
 

itjumper

Joined
Jul 22, 2008
Messages
81
Likes
0
Points
0
#9
Thanks for the advice.

The error is in calss.daemon.inc

a slash is missing in start()

nohup .$szEXE start > /dev/null &

should be

nohup ./$szEXE start > /dev/null &
 

drclue

Joined
Sep 1, 2009
Messages
9
Likes
0
Points
0
#10

itjumper

Joined
Jul 22, 2008
Messages
81
Likes
0
Points
0
#11
if I run $oDaemon->AMIcommand("logout") , won't it kill the session with Server A?
 

drclue

Joined
Sep 1, 2009
Messages
9
Likes
0
Points
0
#12
Howdy itjumper

The FastAGI is a connection between server A and you that was created when the fastAGI call was made.

The AMI connection is a separate connection between you and server A that talks to a different process.
Unless you are actually going to use AMI resources on server A , your free to disconnect and connect
o AMI on server B

If you really want to from your FastAGI context speak to AMI on both servers , you can probably extract
the logic for it from the code and have your FastAGI connection from A, and two AMI connections.

--Doc
 

nsnake

Joined
May 28, 2007
Messages
1
Likes
0
Points
0
#13
You could use Agispeey

http://www.freeiris.org/agispeedy

The Agispeedy is robust implemention of AGI in asterisk. Agispeedy is inconceivable faster than AGI. The result of test shows that by using Agispeedy in asterisk, the performance of system would be improved more than 10 times comparing with AGI.

Agispeedy Features:
2011-5-9 Support Asterisk 1.8.X AGI args syntax not support 1.4.X
implemention of AGI(FastAGI) over TCP Sockets
Work in Stabilize Prefork Mode and Written by Pure Perl.
Easy to Maintain, unlike FastAGI(Dynamic Load AGI no need restart Agispeedy services)
Providing possibility of running AGI on a remote server(Inheriting the FastAGI)
Fast Database Connect(system can hook database connection in child process)
 

drclue

Joined
Sep 1, 2009
Messages
9
Likes
0
Points
0
#14
Actually if you want truly speedy transactions, Web Sockets and AMI are an excellent combination, and not just in browsers either.

In a browser application a status change like perhaps pressing a hold button on a hard phone is reflected so fast that a web page indicator and the red light on the phone appear to come on at the same instant.

This is largely because WebSockets are event driven and totally do away with polling.
When a web socket application is idle , it consume zero bandwidth.

Polling systems have to keep making requests , even if there is no data.

Message overhead is amazing too. When one sends HTTP flavored requests , there
could easily be hundreds or even thousands of bytes transferred beyond the the message itself.


With web sockets , the worst the message overhead gets is about 15 bytes.

Less bandwidth. less CPU usage, less memory usage... etc. etc



--Doc
 

Members online

No members online now.

Latest posts

Forum statistics

Threads
30,913
Messages
130,917
Members
17,589
Latest member
cristian.saiz
Top