[asterisk-users] [1.4] Still can't get it to call back

Gilles codecomplete at free.fr
Fri Feb 25 06:14:46 CST 2011


On Fri, 25 Feb 2011 05:47:36 -0600, Tilghman Lesher
<tilghman at meg.abyt.es> wrote:
>I'm sure there's an equivalent in lua, but the basic idea is that you
>want to fork a
>child, which takes over.  When the parent process dies, control returns to the
>dialplan.

Good idea. uClinux supports vfork() instead of fork(). I'll check if
that makes a difference when used in Asterisk.

Otherwise, I found a work-around: Build the callfile so that it tries
multiple times to dial out, waiting a few seconds before each attempt.
The first try will fail since Zaptel is still ending the previous
call, but it works after that:
============= extensions.conf
exten => h,1,system(/var/tmp/callback.lua)
============= script
#!/var/tmp/lua

file = io.open ("/var/tmp/callback.call","w")
channel = string.format("Channel: Zap/1/123456\n")
file:write(channel)
file:write("Context: callback\n")
file:write("Extension: start\n")
file:write("Priority: 1\n")
file:write("WaitTime: 10\n")
file:write("RetryTime: 10\n")
file:write("MaxRetries: 3\n")
file:close()

os.execute("mv /var/tmp/callback.call /var/tmp/asterisk/outgoing")
============= CLI
-- Starting simple switch on 'Zap/1-1'
...
-- Attempting call on Zap/1/123456 for start at callback:1 (Retry 1)
[Feb 25 12:11:57] NOTICE[6304]: channel.c:2863 __ast_request_and_dial:
Unable to request channel Zap/1/123456
-- Executing [failed at callback:1] NoOp("OutgoingSpoolFailed", "Reason
call failed is 0") in new stack
== Auto fallthrough, channel 'OutgoingSpoolFailed' status is 'UNKNOWN'
[Feb 25 12:11:57] NOTICE[6304]: pbx_spool.c:341 attempt_thread: Call
failed to go through, reason (0) Call Failure (not BUSY, and not
NO_ANSWER, maybe Circuit busy or down?)

-- Attempting call on Zap/1/123456 for start at callback:1 (Retry 2)
> Channel Zap/1-1 was answered.
-- Executing [start at callback:1] NoOp("Zap/1-1", "In callback| CID is
123456") in new stack
-- Executing [start at callback:2] Wait("Zap/1-1", "10") in new stack
-- Executing [start at callback:3] Answer("Zap/1-1", "") in new stack
-- Executing [start at callback:4] Playback("Zap/1-1", "tt-monkeysintro")
in new stack
-- <Zap/1-1> Playing 'tt-monkeysintro' (language 'en')
-- Executing [start at callback:5] Hangup("Zap/1-1", "") in new stack
== Spawn extension (callback, start, 5) exited non-zero on 'Zap/1-1'
-- Hungup 'Zap/1-1'
[Feb 25 12:12:24] NOTICE[6305]: pbx_spool.c:351 attempt_thread: Call
completed to Zap/1/123456
=============

Out of curiosity, I tried the following code in the dialplan, but
Asterisk reads the While condition and simply exits, without jumping
to the "tryagain" section:
===============
exten => h,1,ChanIsAvail(ZAP/1)
;1 = AST_DEVICE_NOT_INUSE
exten => h,n,While($[${AVAILSTATUS} != 1])
exten => h,n,ChanIsAvail(ZAP/1)
exten => h,n,EndWhile()
exten => h,n,Goto(tryagain,start,1)

[tryagain]
exten => start,1,Wait(10)
exten => start,n,Dial(Zap/1/123456)
exten => start,n,NoOp(DIALSTATUS is ${DIALSTATUS})
exten => start,n,Hangup()
===============

I guess ChanIsAvail is useless in the "h" extension.

Thank you.




More information about the asterisk-users mailing list