FreePBX looping forever when agi script forwards to a queue

Hi.

I run AsteriskNow / FreePBX Core 2.7.0.10.

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

[from-internal-custom]
include => ivr-digitick
[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 :
$AGI->set_extension(“2000”);

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…

Olivier

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:

$my_queue=“2000”;
$AGI->set_variable(“NODEST”,$my_queue);
$AGI->set_context(“from-internal”);
$AGI->set_extension($my_queue);

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.

Hi.

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:

$AGI->set_extension(“2000”);

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

[from-queue]
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:

http://www2.elastix.org/component/kunena/3-help/61298-agi--place-a-call-in-a-queue-elastix-20.html

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.