How to avoid loops

Joined: Tue 12 of Aug, 2014

Re: How to avoid loops

Posted:Mon 15 of Jun, 2015 (05:55 UTC)
If you really need to iterate over them, you need to iterate over them.
The general guidance of triple nested loops is to avoid spaghetti code which is hard to follow. If your inner and second loops are functions, this can improve code clarity
Joined: Tue 02 of Jun, 2015

How to avoid loops

Posted:Tue 02 of Jun, 2015 (17:05 UTC)

I've an Asterisk version 1.2.17. I´m facing a problem with loops in two situations:

1 - Each time through the SIP Trunk EP a call goes to a busy number and Asterisk got 487 SIP message (Busy);

2 - Each time a call goes to unallocated number where it receives the 500 SIP message.

In the dialplan I've the following:

exten => 43325,1,Set(number=${CALLERID(number)})
exten => 43325,2,Dial(${TRUNKEP}/${EXTEN},200,rtT)
exten => 43325,3,gotoif($[${HANGUPCAUSE}=500]?6:4)
exten => 43325,4,gotoif($[${HANGUPCAUSE}=486]?6:5)
exten => 43325,5,Dial(${TRUNKTEL}/${EXTEN},200,rtT)
exten => 43325,6,Hangup()

In the CLI window we got the following:
-- Executing Set("SIP/anonymous.invalid-9f690e30", "number=anonymous") in new stack
— Executing Dial("SIP/anonymous.invalid-9f690e30", "SIP/TRUNKSIP-EP/43325|200|rtT") in new stack
— Called TRUNKSIP-EP/43325
— Got SIP response 500 "Server internal failure" back from
— SIP/TRUNKSIP-EP-01155830 is circuit-busy
== Everyone is busy/congested at this time (1:0/1/0)
— Executing GotoIf("SIP/anonymous.invalid-9f690e30", "0?6:4") in new stack
— Goto (incoming-mxone,43325,4)

It seems that the Gotoif command do nothing, right?

Best regards,

Humberto Andrade