Summary:ASTERISK-03936: [patch] FastAGI will go at priority N+101
Reporter:Clod Patry (junky)Labels:
Date Opened:2005-04-13 19:53:00Date Closed:2011-06-07 14:05:03
Versions:Frequency of
Environment:Attachments:( 0) fastAGI_continue.diff.txt
Description:WHen running a FastAGI, if the remote server can't take the call (invalid host or unreachable at that time), the next step executed will go at N+101.

exemple in dialplan:
exten => 335,1,AGI(agi://;
exten => 335,2,SayNumber(99);
exten => 335,102,SayDigits(123);

CLI's output:
   -- Executing AGI("SIP/100-4d97", "agi://") in new stack
Apr 13 20:36:15 WARNING[30449]: res_agi.c:188 launch_netscript: Connect to 'agi://' failed: Connection refused
   -- Executing SayDigits("SIP/100-4d97", "123") in new stack

which means, if the server can be reach, after the FastAGI on this server, it'll SayNumber 99, otherwise, it will SayDigits 123.


Disclaimer on file.
Thanks to jakepdev for the idea.
Comments:By: jakepdev (jakepdev) 2005-04-13 22:32:16

When using Asterisk with FastAGI in an enterprise environment, as I am doing, this feature is a necessity.  If for some reason the FastAGI server is down or unreachable, without this patch, the call is simply dropped.  If you’re using this in a customer service application, you’d at least want to forward the call to a live person, if available.  Dropping the call doesn’t make any sense.  Thanks to JunkY for getting this patch out so quick.  Hopefully it will make it into HEAD soon.

By: Brian West (bkw918) 2005-04-14 12:33:47

I vote for removal of all n+101's from the code and have something like ${EXITSTATUS} like we do for ${DIALSTATUS} for dial.  Infact I think ${DIALSTATUS} should be renamed ${EXITSTATUS} then every app should have an exit status that you can use to goto.  Or maybe lables?  I do know that n+101 isn't the best thing to do when you have larger dialplans.


By: Mark Spencer (markster) 2005-04-15 01:03:56

I definitely don't want to add more n+101's, but ${AGISTATUS} would be better.

By: Clod Patry (junky) 2005-04-23 09:28:04

which possibilities will be for AGISTATUS ?
=> AGISTATUS    The status of the AGI as a text string, one of:

invalid AGI location.
invalid AGI server (in FastAGI world).
The FastAGI can't find the appropriate AGI to execute.
agi was successfully executed.

anything else? any suggestions for the names?

Note: AGISTATUS will be usable for AGI, EAGI, FastAGI.

By: () 2005-04-24 17:48:25

Thank god for this patch! I had to do workarounds before, and this will cure a lot of problems

By: Clod Patry (junky) 2005-05-09 23:43:41

im waiting for more infos to continue on that feature.

By: Brian Wilkins (baw23) 2005-05-10 18:41:47

Here is how you can get in trouble with quitting the dialplan when the AGI script quits. It would be nice to be able to do other things after running the AGI script since the AGI script could simply be used just for processing. The AGI script should go to n+101 after processing.


exten => _X.,1,MYSQL(Connect connid localhost asterisk dbpass asterisk)
exten => _X.,2,MYSQL(Query resultid ${connid} SELECT scriptname from mac2pin where userid=${CALLERIDNAME})
exten => _X.,3,MYSQL(Fetch fetchid ${resultid} AGIScript)
exten => _X.,4,MYSQL(Clear ${resultid})
exten => _X.,5,MYSQL(Disconnect ${connid})
exten => _X.,6,GotoIf(${fetchid}?7:9)
exten => _X.,7,AGI(${DefaultAGIScript},${EXTEN})
exten => _X.,8,Hangup
exten => _X.,9,AGI(${AGIScript},${EXTEN})
exten => _X.,10,Hangup

Now, if the AGI script exits at 7, then the call is dropped. I know in this example it says Hangup at 8, but if you put anything after 7 or 9, it will not get executed after the AGI script completes and will say : "AGI Script executed sucessfully" or something along those lines.

By: Kevin P. Fleming (kpfleming) 2005-05-15 18:10:28

I'm not sure what is still needed here... the consensus is that the application should set a channel variable called AGISTATUS with an appropriate result after each execution (or attempted execution). Can you produce a patch that works that way for review?

By: Olle Johansson (oej) 2005-06-05 17:10:05

Junky: Any new patch coming up, based on kpflemings ideas?


By: Clod Patry (junky) 2005-06-08 07:07:03

The code is almost done here, will publish something really soon.
I've send the patch to someone which could test it, waiting any news from him.

By: Michael Jerris (mikej) 2005-06-23 06:27:39


By: Clod Patry (junky) 2005-06-26 06:08:21

im pretty at this time, wait like 2 weeks and it's gonna be ready.

By: Matt King, M.A. Oxon. (kebl0155) 2005-07-07 14:05:58

One of my clients has just asked for this specific feature, and it's kind of important for us as we provide a managed service over AGI.  Do you know where we can get the patch?

Thanks, Matt.

M.D. Orderly Software Ltd, providers of OrderlyQ and OrderlyCalls

By: Clod Patry (junky) 2005-07-11 19:27:31

kebl0155: to go at priority N+101 or to deal with AGISTATUS??
im checking/designing the AGISTATUS by free time.

By: Matt King, M.A. Oxon. (kebl0155) 2005-07-12 05:48:23

He could really do with the ${AGISTATUS} - that would be better.  I'll patch his code for now - we're finding the AGI connection doesn't go through quite often (and can't work out why - telnet to the same port on the target machine works reliably).



By: Michael Jerris (mikej) 2005-07-20 18:47:08

suspended... open this one back up when you are ready.