[HELP] WaitExten Exits Non Zero, Nested GoSubs

Hello,

I have been working on a dial plan and have implemented call screening using the U option for the Dial Command which calls a subroutine that contains a WaitExten command. When you press any number the WaitExten command exits and the subroutine exits as well, without continuing the dial plan for that subroutine, either by jumping to the selected extension or by continuing the extension it started in. It will continue to connect the call and execute the dial plan after the call.

Asterisk SVN-branch-11-r407818

I get the following error:

Executing [s@subIntMenu:3] WaitExten("SIP/REDACTED-00000002", "20") in new stack
Spawn extension (subIntMenu, s, 3) exited non-zero on 'SIP/REDACTED-00000002'
Abnormal 'Gosub(subIntMenu,s,1(IR))' exit.  Popping routine return locations.

Here is my dial plan:

[code][Internal]

exten => _7XX,1,GoSub(subDialExt,start,1(${EXTEN}))
same => n,GotoIf($["${GOSUB_RETVAL}" = “INVALIDEXT”]?invalid)
same => n,Voicemail(${EXTEN}@default)
same => n(hangup),Hangup()
same => n(invalid),Playback(silence/1&invalid)
same => n,Goto(hangup)

include => InfoRelay

[InfoRelay]

exten => 8001,1,Answer()
same => n,GotoIfTime(09:00-17:59,mon-fri,,?open)
; same => n,GoTo(afterhours)
same => n(open),GoSub(subIRMenuDay,start,1)
same => n(afterhours),GoSub(subIRMenuNight,start,1)
same => n,Hangup()

[subIntMenu]

exten => s,1,Verbose(“Internal Menu”)
same => n,Background(${ARG1}/${ARG1}CallIntro)
same => n,WaitExten(20)

;Leave internal menu and answer the call
exten => 1,1,Return

;Say the caller’s number digit by digit
exten => 2,1,SayDigits(${CallerIdNum})
same => n,Goto(repeat)

; Redirect the call to provided extension
exten => _3XXX,1,SET(GOSUB_RESULT=GOTO:Internal^${EXTEN:1})
same => n,Return

;Continues with the dial plan to the next priority,
exten => 4,SET(GOSUB_RESULT=CONTINUE)
same => n,Return

[subDialExt]
exten => start,1,NoOp(subDialExt: Looking up extension ${ARG1})
same => n,SET(LOCAL(ext)=${ARG1})
same => n,SET(LOCAL(ARGS)=${ARG2})
same => n,Dial(SIP/REDACTED,30,g${ARGS})
same => n,Return(${DIALSTATUS})

[subIRMenuDay]
exten => start,1,NoOp()
same => n,Set(repeat=0)
same => n(loop),Playback(IR/IRDayOP)
same => n,Playback(IR/IRChange)
same => n,Background(IR/IRMenu)
same => n,WaitExten(5)
same => n,Set(repeat=$[${repeat}+1])
same => n,GotoIf($[${repeat} < 5]?loop)
same => n,Hangup()

exten => 3,1,GoSub(subDialExt,start,1,(762,U(subIntMenu^IR)))
;same => n,Queue(TechSupport,55)
same => n,Hangup()

[subIRMenuNight]
exten => start,1,NoOp()
same => n,Set(repeat=0)
same => n,Playback(IR/IRNightOP)
same => n,Playback(IR/IRChange)
same => n(loop),Set(repeat=$[${repeat}+1])
same => n,Background(IR/IRNightMenu)
same => n,WaitExten(5)
same => n(invalid),GotoIf($[${repeat} <= 5]?loop)
same => n,Hangup()

exten => 9,1,Dial(SIP/REDACTED,20,U(subIntMenu^IR)m)
same => n,Hangup()

exten => _7XX,1,GoSub(subDialExt,start,1(${EXTEN}))
same => n,GotoIf($[${GOSUB_RETVAL} = “INVALIDEXT”]?start,invalid)
[/code]

Has anyone had issues with nested GoSub’s?
I googled trying to find a solution but only get swarms of “Do not use with Macros” and -macro results in about 4 results.

I did find examples of people being able to use WaitExten inside of a Subroutine called by the U option for call screening.

The original Call Ext subroutine does a DB lookup and iterates over all the devices an extension has, so its not just a useless Subroutine, in case anyone is poundering why.