Gilles
2011-Feb-18 15:36 UTC
[asterisk-users] [1.4/AGI] CHANNEL STATUS never "down & available"?
Hello I'm using an AGI script in Lua to make a callback through Zaptel. For this to work, I must wait until the channel is idle, or I get this kind of error, even after waiting over 10 seconds after the remote end rings once and hangs up: =============channel.c:2863 __ast_request_and_dial: Unable to request channel Zap/1/123456 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?) ============= According to this article, CHANNEL STATUS=0 means that the line is available: www.voip-info.org/wiki/view/channel+status Here are extensions.conf, the AGI script, and what the CLI says: =============== extensions.conf [from_fxo] exten => s,1,Wait(2) exten => s,n,Set(CID=${CALLERID(num)}) exten => s,n,Wait(10) exten => s,n,Hangup exten => h,1,DeadAGI(/var/tmp/test.lua) =============== AGI script #!/var/tmp/lua for i=1,10 do io.write("CHANNEL STATUS\n") response=io.read() _, _, key, value = string.find(response, "(%a+)=(%d+)") --Channel never "down and available"! if value=="0" then io.write("NOOP Channel idle\n") response=io.read() else io.write("NOOP Channel N.A.\n") response=io.read() end os.execute("/bin/sleep 2") end =============== CLI ... AGI Rx << CHANNEL STATUS AGI Tx >> 200 result=4 AGI Rx << NOOP Channel N.A. AGI Tx >> 200 result=0 AGI Rx << CHANNEL STATUS AGI Tx >> 200 result=4 AGI Rx << NOOP Channel N.A. AGI Tx >> 200 result=0 ... =============== IOW, although I use Hangup() in extensions.conf and wait several seconds before calling "CHANNEL STATUS", the channel is never marked as "down and available". Do I need to perform some extra steps in extensions.conf or in the script for the FXO port to finally be available for a callback? Thank you for any help.
Steve Edwards
2011-Feb-18 15:52 UTC
[asterisk-users] [1.4/AGI] CHANNEL STATUS never "down & available"?
On Fri, 18 Feb 2011, Gilles wrote:> I'm using an AGI script in Lua to make a callback through Zaptel.> =============== AGI script > #!/var/tmp/lua > for i=1,10 do > io.write("CHANNEL STATUS\n") > response=io.read() > > _, _, key, value = string.find(response, "(%a+)=(%d+)") > > --Channel never "down and available"! > if value=="0" then > io.write("NOOP Channel idle\n") > response=io.read() > else > io.write("NOOP Channel N.A.\n") > response=io.read() > end > os.execute("/bin/sleep 2") > endI'm just a 1.2 Luddite... I've never written an AGI in lua, but don't you have to read the AGI environment (from STDIN) before issuing requests? Also, you execute your AGI in the 'h' extension. I think once a channel is hung up, it's state will not change until you reach the end of your dialplan execution and the channel is destroyed. I'm guessing you would have better luck kicking off an external process that checks the channel status via AMI. -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000