Well, I'm about ready to throw Asterisk across the room. Can someone tell me WHY, when you've sent a Dial command to Asterisk via AGI, if the callee hangs up the call, Asterisk sends a return code, but if the caller hangs up, it does not??? This means if an agi script services a call, and after the two parties have finished speaking, the person who initiated the call hangs up, the agi script is still waiting for a result from stdin.... waiting.... waiting..... and it never gets anything because Asterisk didn't send a result code. Good grief! Doug.
> > Subject: > [Asterisk-Users] AGI Flakyness *sigh* > From: > "Douglas Garstang" <dgarstang@oneeighty.com> > Date: > Thu, 16 Feb 2006 09:24:26 -0700 > > To: > "Asterisk Users Mailing List - Non-Commercial Discussion" > <asterisk-users@lists.digium.com> > > > Well, I'm about ready to throw Asterisk across the room. > > Can someone tell me WHY, when you've sent a Dial command to Asterisk via AGI, if the callee hangs up the call, Asterisk sends a return code, but if the caller hangs up, it does not??? > > This means if an agi script services a call, and after the two parties have finished speaking, the person who initiated the call hangs up, the agi script is still waiting for a result from stdin.... waiting.... waiting..... and it never gets anything because Asterisk didn't send a result code. Good grief! > > Doug. >Hi, stop sounding like those people that blame their c-compiler whenever they can't compile their 'Hello world'. I you want help from this list then you shouldn't suggest that all the help full people on this list aren't telling the truth when they tell you that AGI actually works. Start reading the wiki pages on requirements for writing our own python program and then if it doesn't work: post the script involved and not just a few lines from an error output. Freddi
Freddi, Ok... sure... here's the code. It's about as basic as you can get. #!/usr/bin/python import time import string import sys class AGI: def __init__(self): self.env = {} while 1: line = string.strip(sys.stdin.readline()) if line == '': break key,data = string.split(line,':') key = string.strip(key) data = string.strip(data) if key <> '': self.env[key] = data class Call: def __init__(self): pass def route(self): self.agi = AGI() sys.stdout.write("EXEC " + "\"" + "DIAL" + "\" \"" + "SIP/3250072|5|tr" + "\" " + "\n") sys.stdout.flush() resMsg = sys.stdin.readline() sys.stderr.write('[' + resMsg + "]\n") sys.stderr.flush() def main(): newCall = Call() newCall.route() main() Now, here's my Asterisk console output for when a call is connected, and the CALLEE hangs up the call. *CLI> -- Executing AGI("SIP/10000-3a38", "python/iptrouter2.py|3250072") in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/python/iptrouter2.py -- AGI Script Executing Application: (DIAL) Options: (SIP/3250072|5|tr) -- Called 3250072 -- SIP/3250072-7730 is ringing -- SIP/3250072-7730 answered SIP/10000-3a38 -- Attempting native bridge of SIP/10000-3a38 and SIP/3250072-7730 [200 result=-1 ] -- AGI Script python/iptrouter2.py completed, returning 0 == Auto fallthrough, channel 'SIP/10000-3a38' status is 'ANSWER' And here's the console output for when a call is connected, and the CALLER hangs up the call. *CLI> -- Executing AGI("SIP/10000-6e7b", "python/iptrouter2.py|3250072") in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/python/iptrouter2.py -- AGI Script Executing Application: (DIAL) Options: (SIP/3250072|5|tr) -- Called 3250072 -- SIP/3250072-1ee2 is ringing -- SIP/3250072-1ee2 answered SIP/10000-6e7b -- Attempting native bridge of SIP/10000-6e7b and SIP/3250072-1ee2 == Spawn extension (OnNet_Outgoing, 3250072, 1) exited non-zero on 'SIP/10000-6e7b' As you can quite clearly see, Asterisk sends no return code back to the AGI script. I really want to understand why this happens. I also don't like the fact that you don't get a return code from Asterisk for a Dial command until after the call is Hung up. Also, another annoyance. Why can't asterisk send back a return code once the dial is initiated, but before the call is connected? If you don't get a return code until after the call is hung up (and you script has to wait for the result from stdin), how are you supposed to a) perform post call processing and b) check the status of an open call with CHANNEL STATUS? Doug -----Original Message----- From: Freddi Hansen [mailto:fh@danovation.dk] Sent: Thursday, February 16, 2006 10:00 AM To: asterisk-users@lists.digium.com Subject: [Asterisk-Users] RE: AGI Flakyness *sigh*> > Subject: > [Asterisk-Users] AGI Flakyness *sigh* > From: > "Douglas Garstang" <dgarstang@oneeighty.com> > Date: > Thu, 16 Feb 2006 09:24:26 -0700 > > To: > "Asterisk Users Mailing List - Non-Commercial Discussion" > <asterisk-users@lists.digium.com> > > > Well, I'm about ready to throw Asterisk across the room. > > Can someone tell me WHY, when you've sent a Dial command to Asterisk via AGI, if the callee hangs up the call, Asterisk sends a return code, but if the caller hangs up, it does not??? > > This means if an agi script services a call, and after the two parties have finished speaking, the person who initiated the call hangs up, the agi script is still waiting for a result from stdin.... waiting.... waiting..... and it never gets anything because Asterisk didn't send a result code. Good grief! > > Doug. >Hi, stop sounding like those people that blame their c-compiler whenever they can't compile their 'Hello world'. I you want help from this list then you shouldn't suggest that all the help full people on this list aren't telling the truth when they tell you that AGI actually works. Start reading the wiki pages on requirements for writing our own python program and then if it doesn't work: post the script involved and not just a few lines from an error output. Freddi _______________________________________________ --Bandwidth and Colocation provided by Easynews.com -- Asterisk-Users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Andrew. Thanks for the reply. I'm using AGI, not DeadAGI. I don't see how I can do post call processing if Asterisk never returns a return code. My script is blocking, waiting on input from stdin, which it never gets. Actually, now that I think about it, what I think is happening, is that when the caller hangs up the call (instead of the callee) Asterisk immediately ceases execution of the script. Now, why would it do that? There is an AGI command 'CHANNEL STATUS' which you can use to check the status of an open call. If the dial command (even when the caller hangs up) doesn't return a return code to the script until after the call is disconnected, how can I perform a CHANNEL STATUS agi command? The script is still reading from stdin, waiting for a response. Asterisk doesn't send it until the call is disconnected, and which point, my script continues execution and the CHANNEL STATUS command is no longer relevant. Doug. -----Original Message----- From: Andrew Kohlsmith [mailto:akohlsmith-asterisk@benshaw.com] Sent: Thursday, February 16, 2006 11:48 AM To: asterisk-users@lists.digium.com Subject: Re: [Asterisk-Users] RE: AGI Flakyness *sigh* On Thursday 16 February 2006 13:18, Douglas Garstang wrote:> As you can quite clearly see, Asterisk sends no return code back to the AGI > script. I really want to understand why this happens. I also don't like theAre you using AGI() or DeadAGI() ?> until after the call is Hung up. Also, another annoyance. Why can't > asterisk send back a return code once the dial is initiated, but before the > call is connected? If you don't get a return code until after the call is > hung up (and you script has to wait for the result from stdin), how are you > supposed to a) perform post call processing and b) check the status of an > open call with CHANNEL STATUS?It really sounds like you are frustrated because you have assumed a number of things about how Asterisk operates instead of testing it and understand what the system does and does not do. Post-call processing is VERY easy to do, and can be done several ways. You can use the 'h' extension, or the 'g' flag to Dial() or also by using DeadAGI() instead of AGI(). I'm not sure what you mean by "checking the status of an open call with CHANNEL STATUS" but I'll see if anyone else on the list can help. We all get frustrated. It is best not to broadcast this fact to tens of thousands of people. Collateral damage, and all that. -A. _______________________________________________ --Bandwidth and Colocation provided by Easynews.com -- Asterisk-Users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users