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:[EMAIL PROTECTED]
Sent: Thursday, February 16, 2006 10:00 AM
To: [email protected]
Subject: [Asterisk-Users] RE: AGI Flakyness *sigh*
>
> Subject:
> [Asterisk-Users] AGI Flakyness *sigh*
> From:
> "Douglas Garstang" <[EMAIL PROTECTED]>
> Date:
> Thu, 16 Feb 2006 09:24:26 -0700
>
> To:
> "Asterisk Users Mailing List - Non-Commercial Discussion"
> <[email protected]>
>
>
> 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
_______________________________________________
--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