Multiple FastAGI applications running on the same machine

Hi there;

From the Asterisk dial plan, I will like to call multiple AGI applications (done with Asterisk.NET) that are hosted in the same machine.
Something like:

exten => 1,1,Answer
exten => 1,2,DEADAGI(agi://
exten => 1,3,Hangup

exten => 2,1,Answer
exten => 2,2,DEADAGI(agi://
exten => 2,3,Hangup

exten => 3,1,Answer
exten => 3,2,DEADAGI(agi://
exten => 3,3,Hangup

Now, as we all know fastAGI uses port 4573 to establish the connection.
How the 3 applications running will know for which one the connection (or AGI request) is intended for?

Up to now I have one application running fine.
Now how can I do in the machine running the applications ( to run these 3 applications?
What do I have to configure?


You can have only one application listening on a port. What you need to do is program logic into that application to take the request and call the correct handler for that request.

If you’ll notice, the FastAGI protocol is a URL. So the easiest thing to do is split off the the end of the URL and get the object that was requested. Do a simple switch (or if/else statement) and call the correct function to handle that object.

Alternatively, the quick and dirty way to do it, would be to have each FastAGI application listen on a different port, and specify the port in your extensions.conf file. Just know that if you are trying to do a lot of applications this approach is probably not practical.

Also check your development tools, I don’t use Asterisk.Net so I can’t say for sure, but I know that the Asterisk-Java implementation of FastAGI comes with it’s own FastAGI Server. Perhaps your development tools come with one also.


Or maybe create a proxy server for the messages coming from asterisk? For instance, create a third, proxy server which contains the logic to route the request to the appropriate consumer.

This might be something to consider if those two processes are unrelated and you would like to modularize your system.