FreePBX looping forever when agi script forwards to a queue


I run AsteriskNow / FreePBX Core

I defined an custom IVR function in /etc/asterisk/extensions_custom.conf

include => ivr-digitick
exten => 10001,1,Wait(1)
exten => 10001,2,Answer
exten => 10001,3,AGI(/var/www/html/ivr/agi/ivr.agi)

At the end of the ivr.agi, i forward the call to a queue (2000) with perl command :

This make Asterisk go to an endless loop with 100% CPU . Logs report millions of block:

– Executing [[email protected]:1] Set(“Local/[email protected];2”, “QAGENT=h”) in new stack
– Executing [[email protected]:2] Goto(“Local/[email protected];2”, “,1”) in new stack
– Goto (from-queue,h,1)

Any help welcome…


Ok I understand, and I’ll fix my script properly.
Thanks !

Olivier Fauchon

Hi …

After some debugging, I found that NODEST was undefined, and that was the reason of the loop.

So I added the following definitions:


That works for me, no more loops for the moment

I’ll try to replace the hardcoded $my_queue with something like :
$my_queue = $AGI->get_variable(“NODEST”); at the begining of the agi script.

Olivier Fauchon

you need to set the priority, the rest of that will be handled in the queue context, otherwise you are going to run into other problems.

You should not have to set the NODEST if done right.

you set the extension, but what about the priority, etc.

it sounds like you are not redirecting it properly. Furthermore, there could be other issues going on depending on your dialplan and how the original AGI script is called in the first place.

Generally speaking, if you fire a call to prioirty 1 of the Queue code, then it should take care of everything else you need.


Actually, my AGI script forwards the call to the queue “2000”. This queue works perfectly when called directly with an ip phone.

Problems are caused by the AGI redirection itself:


The problem seems to be there : Maybe related to NODEST variable that comes undefined at the end of the AGI.

include => from-queue-custom
exten => 2000,1,Goto(from-queue-exten-only,${QAGENT},1)
exten => 2001,1,Goto(from-internal,${QAGENT},1)
exten => 2002,1,Goto(from-internal,${QAGENT},1)
exten => 2003,1,Goto(from-internal,${QAGENT},1)
exten => _.,1,Set(QAGENT=${EXTEN})
exten => _.,n,Goto(${NODEST},1)

Someone reported a similar problem:

Olivier Fauchon

make sure you forward the call to the Queue Dialplan that FreePBX generates.

Doing anything else will not properly setup the required parameters needed for the Queue dialplan to operate properly.