[Asterisk-Users] Re: Why does this Macro Loop?

Tony Mountifield tony at softins.clara.co.uk
Wed Apr 13 14:18:26 MST 2005


In article <20050413194507.80404.qmail at web41628.mail.yahoo.com>,
Mystery Glitch <mr_e_glitch at yahoo.com> wrote:
> 
> In my [incoming] context I have something like this:
> exten => 8885861575,1,Macro(vrforward,${EXTEN},8136361451)

But HOW MUCH like the above is what you ACTUALLY have?

Your diagnostic information suggests that you might have something
in that context that is matching the h extension and calling the
macro again. The following would do it:

exten => _.,1,Macro(vrforward,${EXTEN},8136361451)

You need to show us the whole context, or at least all the parts
that can call the macro.

Your log also suggests that your context is not [incoming] at all,
but rather [company-in]

> And thie Macro contains this:
> [macro-vrforward]
> exten => s,1,GotoIF($[${CALLERIDNUM} = 9545551111]?40:2)
> exten => s,2,SetGroup(${ARG1})
> exten => s,3,CheckGroup(3)
> exten => s,4,SetAccount(${ARG1})
> exten => s,5,Dial(SIP/1${ARG2}@termprovider,30,o)
> exten => s,40,AGI(checkin|${ARG1})
> exten => s,41,Hangup
> 
> 
> Now, when I use my other server to set the caller ID to 9545551111 and place the call, I get
> this strange loop:
> 
> server*CLI>
>     -- Executing Macro("SIP/5060-0825a308", "vrforward|8885861575|8136361451") in new stack

Look at the channel name - it ends a308.

>     -- Executing GotoIf("SIP/5060-0825a308", "1?40:2") in new stack
>     -- Goto (macro-vrforward,s,40)
>     -- Executing AGI("SIP/5060-0825a308", "checkin|8885861575") in new stack
>     -- Launched AGI Script /var/lib/asterisk/agi-bin/checkin
> 
>     -- Executing Macro("SIP/5060-0829c958", "vrforward|8885861575|8136361451") in new stack

Now look at this channel name - it ends c958. This is a fresh SIP call,
not a loop of the first one.

Check the extension logic in your other server, so see why it is placing
two SIP calls instead of one.

>     -- Executing GotoIf("SIP/5060-0829c958", "1?40:2") in new stack
>     -- Goto (macro-vrforward,s,40)
>     -- Executing AGI("SIP/5060-0829c958", "checkin|8885861575") in new stack
>     -- Launched AGI Script /var/lib/asterisk/agi-bin/checkin
>     -- AGI Script checkin completed, returning 0
>     -- Executing Hangup("SIP/5060-0825a308", "") in new stack
>   == Spawn extension (macro-vrforward, s, 41) exited non-zero on 'SIP/5060-0825a308' in
> macro 'vrforward'
>   == Spawn extension (company-in, 8885861575, 1) exited non-zero on 'SIP/5060-0825a308'
>     -- AGI Script checkin completed, returning 0
>     -- Executing Hangup("SIP/5060-0829c958", "") in new stack
>   == Spawn extension (macro-vrforward, s, 41) exited non-zero on 'SIP/5060-0829c958' in
> macro 'vrforward'
>   == Spawn extension (company-in, 8885861575, 1) exited non-zero on 'SIP/5060-0829c958'
> 
>     -- Executing Macro("SIP/5060-0829c958", "vrforward|8885861575|8136361451") in new stack

This is the macro call that I think may be from something matching
the h extension.

>     -- Executing GotoIf("SIP/5060-0829c958", "1?40:2") in new stack
>     -- Goto (macro-vrforward,s,40)
>     -- Executing AGI("SIP/5060-0829c958", "checkin|8885861575") in new stack
>     -- Launched AGI Script /var/lib/asterisk/agi-bin/checkin
>     -- AGI Script checkin completed, returning 0
>     -- Executing Hangup("SIP/5060-0829c958", "") in new stack
>   == Spawn extension (macro-vrforward, s, 41) exited non-zero on 'SIP/5060-0829c958' in
> macro 'vrforward'
>   == Spawn extension (company-in, 8885861575, 1) exited non-zero on 'SIP/5060-0829c958'
>     -- Accepting AUTHENTICATED call from 209.237.227.185, requested format = 4, actual format = 4
>     -- Executing SetCIDNum("IAX2/vr1 at vr1/14", "") in new stack

This is another completely different call, unrelated to your SIP calls.

>     -- Executing SetGroup("IAX2/vr1 at vr1/14", "NOC Phone") in new stack
>     -- Executing CheckGroup("IAX2/vr1 at vr1/14", "3") in new stack
>     -- Executing Dial("IAX2/vr1 at vr1/14", "SIP/18885861575 at termprovider|30|o") in new stack
>     -- Called 18885861575 at termprovider
> 
>     -- Executing Macro("SIP/5060-0829c958", "vrforward|8885861575|8136361451") in new stack
>     -- Executing GotoIf("SIP/5060-0829c958", "0?40:2") in new stack
>     -- Goto (macro-vrforward,s,2)
>     -- Executing SetGroup("SIP/5060-0829c958", "8885861575") in new stack
>     -- Executing CheckGroup("SIP/5060-0829c958", "3") in new stack
>     -- Executing SetAccount("SIP/5060-0829c958", "000-8885861575") in new stack
>     -- Executing Dial("SIP/5060-0829c958", "SIP/18136361451 at termprovider|30|o") in new stack
>     -- Called 18136361451 at termprovider
>     -- SIP/termprovider-d337 is making progress passing it to SIP/5060-0829c958
>     -- SIP/termprovider-a01f is making progress passing it to IAX2/vr1 at vr1/14
>   == Spawn extension (company-vr1, 18885861575, 4) exited non-zero on 'IAX2/vr1 at vr1/14'
>     -- Executing Hangup("IAX2/vr1 at vr1/14", "") in new stack
>   == Spawn extension (company-vr1, h, 1) exited non-zero on 'IAX2/vr1 at vr1/14'
>     -- Hungup 'IAX2/vr1 at vr1/14'
>   == Spawn extension (macro-vrforward, s, 5) exited non-zero on 'SIP/5060-0829c958' in macro
> 'vrforward'
>   == Spawn extension (company-in, 8885861575, 1) exited non-zero on 'SIP/5060-0829c958'
> 
> 
> My Macro is a simple shell script:

I think you meant your AGI, not Macro

> #!/bin/sh
> 
> lynx -dump 'http://www.ourdomain.com/manual.php?pg=admin/cronjobs/origination-check2&i_did='$1
> 
> 
>  
> 
> ------------
> 
> Why is it looping? It executes the right goto once, and then it starts all over again, and
> does it right again, and then starts over and this time sends it to the forwarded number,
> and the receiver gets the callerid all messed up, either all 0's or some strange local
> number, probably the local provider being used number.  The hangup doesn't terminate the
> channel, it just cyles again, after enough cycles the caller id gets lost and then ends up
> terminating.

Hangup doesn't stop processing; it hangs up the channel and then jumps
to the h extension. If your context has any exten that could match h,
it will be executed.

> This system is designed to test our origination numbers, if we call any of our
> numbers with that specific caller id, the system should redirect it to an agi which sends it
> to a url to be added to a database. Then using Nagios we can check that url and make sure
> our numbers are all working.
> 
> I've tried Answer, AGI, Hangup  but to no avail. I then tried DeadAGI, Hangup, to no avail.
> So what's going on?

We can't say for certain, because you've only provided an approximation
of what you're running, rather than actually what you're running.
But I hope the suggestions above do help.

Cheers
Tony
-- 
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org



More information about the asterisk-users mailing list