Interesting.

Could you tell me what commands?

Obviously the channel stays open if the command is still running, but I am not 
sure what command is in that kind of loop.

You rock, and I will look into this tomorrow. Great research!

Let me know if you have any more discoveries.

-Brandon

----- Original Message -----
From: "David Kerr" <[email protected]>
To: "Asterisk GUI project discussion" <[email protected]>
Sent: Thursday, December 18, 2008 4:53:31 PM GMT -06:00 Central America
Subject: [asterisk-gui] executecommand script


Brandon, et al. 
One issue I have been seeing a lot of is a channel remaining open in the 
asterisk_guitools context, executecommand "extension". Invariably if I look at 
the open channels I will see one or more channels in "Ring" state often with a 
duration in the thousands, if not tens or hundreds of thousands of seconds. 
They just never go away, and clicking on "hangup" in the active channels page 
does nothing. 


I have been investigating this for some time to try and find a solution, but 
rather than finding a solution I just find one gotcha after another. First the 
context (as built by pbx.js) looks like... 



exten=executecommand,1,System(${command}) 

exten=executecommand,n,Hangup 



The parameters to the System() call being setup in astman.js. First thing I 
observed is that there is no timeout condition... there is a timeout set on the 
call to the AMI in astman.js (for 60 seconds!) but that timeout is only for 
until control is passed to the context? ( 
http://www.voip-info.org/wiki/view/Asterisk+Manager+API+Action+Originate ) and 
not a timeout for the System() command inside the context. So I considered 
adding a timeout(absolute) to the script. But find that this only works after 
an Answer ( http://www.voip-info.org/wiki/view/Asterisk+cmd+AbsoluteTimeout). 
.. which is when I realized that the "call" is never answered... maybe that is 
why it sometimes gets stuck on "Ring". So I tried... 



exten=executecommand,1,Answer 
exten=executecommand,n,Set(TIMEOUT(absolute)=30) 
exten=executecommand,n,System(${command}) 
exten=executecommand,n,Hangup 

exten=T,1,Hangup 



But on testing this I find that while it works when the command being executed 
is VERY quick, it fails when the command is slow (I'm doing some other 
enhancements that execute a wget, which needs time (1 or 2 seconds) to pull 
results from the network). It fails because as soon as the call is "answered" 
control returns to the callback function set in astman.js... which then 
attempts to read the result from the command (as saved in sysinfo_output.html), 
which may not have completed yet. If I move the Answer statement to after the 
System call, then it works again... but then the behavior of Timeout(absolute) 
is undefined (according to 
http://www.voip-info.org/wiki/view/Asterisk+cmd+AbsoluteTimeout ) which states 
that extension "T" will never get called. 


So I am in a catch 22 situation. 


I also tried changing astman.js in the systemCmd() function... rather than make 
a request with a "noop" application, I told it to use "System" and passed some 
data into it (also modifying the context not to call System). Same problem... 
because of the asynchronous nature of the request, control passes to the 
callback before the command I want to execute completes. I have not tried 
making a synchronous request on the asterisk manager API because I don't want 
to hang the user interface while the command executes on the server. 


So... any ideas. I'd like a way to stop these phantom channels remaining open? 


Thanks, 
David 






_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--

asterisk-gui mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-gui

-- 
******************************
Brandon Kruse
Software Technician
Digium, Inc.
150 West Park Loop, Suite 100
Huntsville, AL 35806
Phone: +1-256-428-6115
877.546.8963
877.linux.me!
www.digium.com
www.asterisk.org
******************************

_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--

asterisk-gui mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-gui

Reply via email to