Wait function issue for call

Hi,

I have written small script for dialing the call and when call no answer it will move to NOANSWER context and when I put in dial plan to wait(seconds) for redial again then call getting hungup every time. See my below dial plan for the more details.

[outdial]

exten => *8899,1,Dial(SIP/${DNUM},30)
exten => *8899,n,Goto(s-${DIALSTATUS},1)

;;if the line is busy
exten => s-BUSY,1,Verbose(SIP/${WTrunk}/${DNUM}->The number is busy ${HANGUPCAUSE})
exten => s-BUSY,n,Wait(30)
exten => s-BUSY,n,Goto(*8899,1)

;if the channel is not avilable
exten => s-CHANUNAVAIL,1,Verbose(SIP/${WTrunk} VOIP Trunk is not available : ${HANGUPCAUSE})
exten => s-CHANUNAVAIL,n,Wait(30)
exten => s-CHANUNAVAIL,n,Goto(*8899,1) ;;redial again after some time
;exten => s-CHANUNAVAIL,n,Hangup()

;if the no answer
exten => s-NOANSWER,1,Verbose(Wait for some time to redial)
exten => s-NOANSWER,n,Wait(30)
exten => s-NOANSWER,n,Goto(*8899,1) ;;redial number again

;if the line having the congestion
exten => s-CONGESTION,1,Verbose(SIP/${WTrunk}/${DNUM}->Congestion : ${HANGUPCAUSE})
exten => s-CONGESTION,n,Verbose(Increase the attempt counter and update into the database)
exten => s-CONGESTION,n,Wait(30) ;;wait for some time and try again
exten => s-CONGESTION,n,Goto(*8899,1) ;;redial again

When in No Answer state I put the call wait for 30 seconds it will hangup after some time, below is the asterisk console log

  • Attempting call on Local/*8899@wakeupout for *7777@wakeupout:1 (Retry 1)
    – Executing [*8899@wakeupout:1] Verbose(“Local/*8899@wakeupout-112b;2”, “1312356700.62->Dialing Number 9999 with Wait time 20, Wakeup Trunk 2001”) in new stack
    – Executing [*8899@wakeupout:2] Dial(“Local/*8899@wakeupout-112b;2”, “SIP/9999,20”) in new stack
    == Using SIP RTP CoS mark 5
    – Called 9999
    – SIP/9999-00000011 is ringing
    – Nobody picked up in 20000 ms
    – Executing [*8899@wakeupout:3] Verbose(“Local/*8899@wakeupout-112b;2”, “1312356700.62->Dial status : NOANSWER, Hangup cause : 0”) in new stack
    – Executing [*8899@wakeupout:4] Goto(“Local/*8899@wakeupout-112b;2”, “s-NOANSWER,1”) in new stack
    – Goto (wakeupout,s-NOANSWER,1)
    – Executing [s-NOANSWER@wakeupout:1] Verbose(“Local/*8899@wakeupout-112b;2”, “SIP/2001/9999->No answer : 0, Called Count : 0, Account :17”) in new stack
    Called Count : 0, Account :17
    – Executing [s-NOANSWER@wakeupout:2] GotoIf(“Local/*8899@wakeupout-112b;2”, “1?wakeupout,r-NOANSWER,1”) in new stack
    – Goto (wakeupout,r-NOANSWER,1)
    – Executing [r-NOANSWER@wakeupout:1] Verbose(“Local/*8899@wakeupout-112b;2”, “Guest Extension No-Answer”) in new stack
    Guest Extension No-Answer
    – Executing [r-NOANSWER@wakeupout:2] AGI(“Local/*8899@wakeupout-112b;2”, “wakeup/WakeupNoAnswer.agi,17,1423.temp.17.9999.call”) in new stack
    – Launched AGI Script /var/lib/asterisk/agi-bin/wakeup/WakeupNoAnswer.agi
    wakeup/WakeupNoAnswer.agi,17,1423.temp.17.9999.call: setting up the operator flag…
    – <Local/*8899@wakeupout-112b;2>AGI Script wakeup/WakeupNoAnswer.agi completed, returning 0
    – Executing [r-NOANSWER@wakeupout:3] Verbose(“Local/*8899@wakeupout-112b;2”, “OperatorCall = no”) in new stack
    OperatorCall = no
    – Executing [r-NOANSWER@wakeupout:4] GotoIf(“Local/*8899@wakeupout-112b;2”, “0?wakeupout,h-NOANSWER,1”) in new stack
    – Executing [r-NOANSWER@wakeupout:5] Set(“Local/*8899@wakeupout-112b;2”, “i=300”) in new stack
    – Executing [r-NOANSWER@wakeupout:6] Wait(“Local/*8899@wakeupout-112b;2”, “30”) in new stack
    == Spawn extension (wakeupout, r-NOANSWER, 6) exited non-zero on 'Local/*8899@wakeupout-112b;2’

    I got the Spawn extension exited non-zero error. Can you pls let me know what is happening here… why it is hanging ?

Note : {DNUM} is the channel variable which hold the extension number which is set from the AGI script.

Thanks in advance.

Ketan

It’s exiting because the caller hungup, possibly because their network imposes a time limit on unanswered calls. Normally you shouldn’t explicitly answer calls in the dialplan, because people get charged for listening to ring back tone, but, in this case, you probably should. I would do it after the first failure, and also issue a voice announcement, or go to music on hold, so they know charging has started.

Its not like that.

See I made one call file for calling the *8899 extension. Actually my issue is call file never provide the call status whether it is answered, no-answer or busy. I have change my logic and do the dialing from the dial plan. Actually I am developing the Wake-call system. If the user not answered the call 3 times and after that call will be dial on operator extension. So I have wrote the dial plan for that. Once call is not answered by guest, than it will wait for 30 seconds to re-dial again that number. for wait 30 seconds i have wrote Wait(30) in my dial plan. But due to some issue after some time dial plan get exit with swapn extension error.

Spawn extension … non-zero is not an error, although it can be caused by an error. It simply means the current application returned a non-zero return code, and the most likely reason for that is that the channel running the dialplan hung up, or the called channel for Dial, Queue, etc., has hungup after a successful connection.

The wait application is this:

if (data && (s = atof(data)) > 0.0) { ms = s * 1000.0; return ast_safe_sleep(chan, ms); } return 0;

ast_safe_sleep isn’t much bigger, and would only return non-zero if the channel had been hung up.

As per my dial plan it should be execute the next line (exten => s-NOANSWER,n,Goto(*8899,1)) instead of hangup. Can you help me how can I find out the reason why it is hangup ?

Because it received CANCEL or BYE (probably CANCEL) on the incoming line, or if Originate/Call File, presumably a timer expired.

What is bridged to Local/*8899@wakeupout-112b;1?

current call channel to put in the wait mode for 30 seconds. yes, you are correct might be there is some timeout issue. But, how can I increase the time for that channel call ?

In that case, the device connected to that channel timed out because the call hadn’t been answered.

but the there is no device for that *8899, it is the extension name defined in the dial plan to do the the dialing again and again till call get answered. But the loop process get time out but what is the reason ? and How can I increase the timing for that ?

I asked you what was bridged to the other side of that local channel. You gave a non-specific answer. I gave a generic answer that whatever created the channel that was bridged to the other side had closed the call.

Hi,

Maybe it’s a issue with a phone you are using, maybe it times out in <30sec if there is no answer.
Try to lover that to 20 or maybe 10 sec and see if it will work.
Hope this helps
Mirko

However you did indicate something was bridged to it, which excluded the possibility that you were talking about the A side of an Originate/Call File.

Both of the latter have timeouts. I think the Call File one is fixed.

See my call file below what I made for dialing the extension number for the wake-up call

Below content of my call file

Channel:Local/*8899@wakeupout
context:wakeupout
account:17
Setvar:DNUM=9999
Setvar:WKID=17
Setvar:WTime=20
Setvar:CCount=0
Setvar:ACount=0
Setvar:CFile=1423.temp.17.9999.call
Setvar:WTrunk=2001
Setvar:WSnoozetime=5
Extension: *7777

Once the call file fired then call the *8899 extension from the dial plan

[wakeupout]

;exten => *8899,1,Verbose(${UNIQUEID}->Wakeup call outgoing context)
exten => *8899,1,Verbose(${UNIQUEID}->Dialing Number ${DNUM} with Wait time ${Wtime}, Wakeup Trunk ${WTrunk})
;exten => *8899,n,Dial(SIP/${WTrunk}/${DNUM},${WTime}) ;Dial the extension number for the wakeup call
exten => *8899,n,Dial(SIP/${DNUM},${WTIME})
exten => *8899,n,Verbose(${UNIQUEID}->Dial status : ${DIALSTATUS}, Hangup cause : ${HANGUPCAUSE})
exten => *8899,n,Goto(s-${DIALSTATUS},1)
exten => *8899,n,Verbose(${UNIQUEID}->Account Code : ${CDR(accountcode)})

;;following state call jump in not answer or failed cases…
exten => s-BUSY,1,Verbose(SIP/${WTrunk}/${DNUM}->The number is busy ${HANGUPCAUSE})
exten => s-BUSY,n,GotoIf($[${CDR(accountcode)} != “operator”]?wakeupout,r-NOANSWER,1)
exten => s-BUSY,n,Wait(30)
exten => s-BUSY,n,Goto(*8899,1) ;;redial operator number again

;exten => s-BUSY,n,Wait(30) ;;wait for and try again for dialing the same number, update the call counter here…
;exten => s-BUSY,n,Goto(*8899,1) ;;Redial again
;exten => s-BUSY,n,Hangup()

exten => s-CHANUNAVAIL,1,Verbose(SIP/${WTrunk} VOIP Trunk is not available : ${HANGUPCAUSE})
exten => s-CHANUNAVAIL,n,Wait(30)
exten => s-CHANUNAVAIL,n,Goto(*8899,1) ;;redial again after some time
;exten => s-CHANUNAVAIL,n,Hangup()

exten => s-NOANSWER,1,Verbose(SIP/${WTrunk}/${DNUM}->No answer : ${HANGUPCAUSE}, Called Count : ${CCount}, Account :${CDR(accountcode)})
exten => s-NOANSWER,n,GotoIf($[${CDR(accountcode)} != “operator”]?wakeupout,r-NOANSWER,1)
exten => s-NOANSWER,n,Verbose(Operator Call Detected for No-Answer)
exten => s-NOANSWER,n,Wait(30)
exten => s-NOANSWER,n,Goto(*8899,1) ;;redial operator number again

exten => r-NOANSWER,1,Verbose(Guest Extension No-Answer)
exten => r-NOANSWER,n,AGI(wakeup/WakeupNoAnswer.agi,${WKID},${CFile})
exten => r-NOANSWER,n,Verbose(OperatorCall = ${operatorcall})
exten => r-NOANSWER,n,GotoIf($[${operatorcall} = “yes”]?wakeupout,h-NOANSWER,1)
exten => r-NOANSWER,n,Set(i=${MATH(${WSNoozetime}*60,int)})

exten => h-NOANSWER,1,Hangup()

exten => s-CONGESTION,1,Verbose(SIP/${WTrunk}/${DNUM}->Congestion : ${HANGUPCAUSE})
exten => s-CONGESTION,n,Verbose(Increase the attempt counter and update into the database)
exten => s-CONGESTION,n,Wait(30) ;;wait for some time and try again
exten => s-CONGESTION,n,Goto(*8899,1) ;;redial again

exten => *7777,1,Verbose(SIP/${WTrunk}/${DNUM}->Answer the Call)
exten => *7777,n,AGI(wakeup/sjwakeup.agi,${CFile})
exten => *7777,n,Verbose(Here we have to check the flag value if the call hangup without pressing any digit by user)
exten => *7777,n,Verbose(WFlag Value : ${WFlag})
exten => *7777,n,GotoIf($[${WFlag} = “4”]?wakeupout,snooze,1)
exten => *7777,n,Hangup()

exten => snooze,1,Verbose(Auto Snooze call)
exten => snooze,n,AGI(wakeup/WakeupTerminate.agi,${WKID},${CFILE},“4”)
exten => snooze,n,Hangup()

See my dial plan to make the retry in the failure of call in state of No-Answer,Busy,Congestion and Channel Unavailable.

So it is the A side from a call file.

WaitTime:
Number of seconds the system waits for the call to be answered. If not specified, defaults to 45 seconds.

the-asterisk-book.com/unstab … -file.html

I suspect this is a new feature, as I can’t find it in 1.6.1.0. I think earlier versions use a fixed value of 45 seconds.

yes, thats true. Thanks man. you save my life.

I have added the Waitime in the call file and I added the 1000 secs. Now problem has been resolved. it is working now.

Thanks Thanks… :smile: :smiley: