Hello No matter what I try, Asterisk still fails dialing back through a callfile built through an AGI script. The whole thing works fine when the original call that triggers Asterisk is from an internal extension (Xlite), but it fails when it's from my cellphone ringing through the FXO/Zaptel port and I want to wait a few seconds and call back through the FXO/Zaptel. Could it that even though the Zap channel is dead when calling the script in the "h" extension, for some reason, the channel is still in use at that point, so even an AGI script won't be able to make an outgoing call through the FXO? Here are the relevant parts: ======== extensions.conf [internal] ;Call from Xlite to simulate incoming external call exten => 8888,1,Dial(Local/s at from_fxo) [from_fxo] ;Incoming call just to trigger things exten => s,1,Wait(2) exten => s,n,Set(CID=${CALLERID(num)}) exten => s,n,Wait(2) exten => s,n,Hangup ;Call script to build callfile exten => h,1,DeadAGI(/var/tmp/callback.lua,${CID}) ;Context used by callfile [callback] ;Zaptel doesn't support call progress, so just wait 10s exten => start,1,Wait(10) exten => start,n,Answer() exten => start,n,Playback(tt-monkeysintro) exten => start,n,Hangup() ======== AGI script #!/var/tmp/lua --Must first empty stdin while true do local line = io.read() if line == "" then break end -- Without line below, script never ends io.write("NOOP ",line,"\n") end 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:close() os.execute("mv /var/tmp/callback.call /var/tmp/asterisk/outgoing") ======== CLI output ip04*CLI> -- Starting simple switch on 'Zap/1-1' -- Executing [s at from_fxo:1] Wait("Zap/1-1", "2") in new stack -- Executing [s at from_fxo:2] Set("Zap/1-1", "CID=123456") in new stack -- Executing [s at from_fxo:3] Wait("Zap/1-1", "2") in new stack -- Executing [s at from_fxo:4] Hangup("Zap/1-1", "") in new stack == Spawn extension (from_fxo, s, 4) exited non-zero on 'Zap/1-1' -- Executing [h at from_fxo:1] DeadAGI("Zap/1-1", "/var/tmp/callback.lua|123456") in new stack -- Launched AGI Script /var/tmp/test7.lua AGI Tx >> agi_request: /var/tmp/test7.lua AGI Tx >> agi_channel: Zap/1-1 AGI Tx >> agi_language: en AGI Tx >> agi_type: Zap AGI Tx >> agi_uniqueid: 1298539792.116 AGI Tx >> agi_callerid: 123456 AGI Tx >> agi_calleridname: unknown AGI Tx >> agi_callingpres: 0 AGI Tx >> agi_callingani2: 0 AGI Tx >> agi_callington: 0 AGI Tx >> agi_callingtns: 0 AGI Tx >> agi_dnid: unknown AGI Tx >> agi_rdnis: unknown AGI Tx >> agi_context: from_fxo AGI Tx >> agi_extension: h AGI Tx >> agi_priority: 1 AGI Tx >> agi_enhanced: 0.0 AGI Tx >> agi_accountcode: AGI Tx >> AGI Rx << NOOP agi_request: /var/tmp/test7.lua AGI Tx >> 200 result=0 AGI Rx << NOOP agi_channel: Zap/1-1 AGI Tx >> 200 result=0 AGI Rx << NOOP agi_language: en AGI Tx >> 200 result=0 AGI Rx << NOOP agi_type: Zap AGI Tx >> 200 result=0 AGI Rx << NOOP agi_uniqueid: 1298539792.116 AGI Tx >> 200 result=0 AGI Rx << NOOP agi_callerid: 123456 AGI Tx >> 200 result=0 AGI Rx << NOOP agi_calleridname: unknown AGI Tx >> 200 result=0 AGI Rx << NOOP agi_callingpres: 0 AGI Tx >> 200 result=0 AGI Rx << NOOP agi_callingani2: 0 AGI Tx >> 200 result=0 AGI Rx << NOOP agi_callington: 0 AGI Tx >> 200 result=0 AGI Rx << NOOP agi_callingtns: 0 AGI Tx >> 200 result=0 AGI Rx << NOOP agi_dnid: unknown AGI Tx >> 200 result=0 AGI Rx << NOOP agi_rdnis: unknown AGI Tx >> 200 result=0 AGI Rx << NOOP agi_context: from_fxo AGI Tx >> 200 result=0 AGI Rx << NOOP agi_extension: h AGI Tx >> 200 result=0 AGI Rx << NOOP agi_priority: 1 AGI Tx >> 200 result=0 AGI Rx << NOOP agi_enhanced: 0.0 AGI Tx >> 200 result=0 AGI Rx << NOOP agi_accountcode: AGI Tx >> 200 result=0 -- AGI Script /var/tmp/callback.lua completed, returning 0 -- Hungup 'Zap/1-1' -- Attempting call on Zap/1/123456 for start at callback:1 (Retry 1) [Feb 24 09:29:58] NOTICE[6097]: channel.c:2863 __ast_request_and_dial: Unable to request channel Zap/1/123456 [Feb 24 09:29:58] NOTICE[6097]: 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?) ======= Thank you for any help.
Tony Mountifield
2011-Feb-24 13:11 UTC
[asterisk-users] [1.4] Still can't get it to call back
In article <jg9cm6pqkit0q3oi5aacabi7dfql7stlue at 4ax.com>, Gilles <codecomplete at free.fr> wrote:> Hello > > No matter what I try, Asterisk still fails dialing back through a > callfile built through an AGI script. > > The whole thing works fine when the original call that triggers > Asterisk is from an internal extension (Xlite), but it fails when it's > from my cellphone ringing through the FXO/Zaptel port and I want to > wait a few seconds and call back through the FXO/Zaptel. > > Could it that even though the Zap channel is dead when calling the > script in the "h" extension, for some reason, the channel is still in > use at that point, so even an AGI script won't be able to make an > outgoing call through the FXO?Yes, that is the reason. The easiest thing is probably to put in a delay if os.execute allows full shell syntax:> os.execute("mv /var/tmp/callback.call /var/tmp/asterisk/outgoing")os.execute("(sleep 2;mv /var/tmp/callback.call /var/tmp/asterisk/outgoing)&") Alternatively, you can set the mtime of the file you created in /var/tmp to two or three seconds in the future - does lua have something like file.utime or os.utime? The pbx spooler in Asterisk will not execute call files with an mtime still in the future. Cheers Tony -- Tony Mountifield Work: tony at softins.co.uk - http://www.softins.co.uk Play: tony at mountifield.org - http://tony.mountifield.org
Steve Edwards
2011-Feb-24 15:31 UTC
[asterisk-users] [1.4] Still can't get it to call back
On Thu, 24 Feb 2011, Gilles wrote:> No matter what I try, Asterisk still fails dialing back through a > callfile built through an AGI script.I don't think it has anything to do with the method used to create the call file.> ======== AGI script > #!/var/tmp/lua > > --Must first empty stdin > while true do > local line = io.read() > if line == "" then break end > -- Without line below, script never ends > io.write("NOOP ",line,"\n") > endThis script violates the AGI protocol. In addition to suggesting to use an established library, I'd suggest picking a language and sticking with it. Personally, I use C because it's the sharpest tool in my toolbox. -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000