[asterisk-dev] Problem with asterisk 1.4.13 and AGI variables
Godson Gera
godson.g at gmail.com
Sat Dec 1 06:07:07 CST 2007
> I wrote an AGI programme that dials extensions and after i read variables
> like "*ANSWEREDTIME" "DIALSTATUS"*
> my problem is : if the callee hangup, i can capture the variables but if
> the caller hangup, it is impossible to get the variables. this is my code in
> perl
>
> $callstart=localdate(time);
>
> $AGI->set_callerid("$trunk{'cliname'}<$trunk{'cliname'}>");
>
> $dialstr =
> $trunk{'strcon'}.$phoneno.'@'.$trunk{'outboundname'}.'|30|L('.($maxmins * 60
> * 1000) . ":60000)";
>
> $res = $AGI->exec("DIAL $dialstr");
>
> $answeredtime = $AGI->get_variable("ANSWEREDTIME");
>
> $dialstatus = $AGI->get_variable("DIALSTATUS");
>
>
That behavior is normal as asterisk closes the connection to your AGI script
when caller hangsup. A quick hack is, you can use DeadAGI application in
your dial plan to invoke your AGI script then you'll be able read those
variables, even if the caller hangs up. But then your script must be quick
to hang up the channel, once you read those variables. However this is not
recommended as it has its side effects like if your scripts fails to hangup
the channel it will still be considered as up by asterisk.
The safe way is reading the CDR events using AMI, to get accurate billable
seconds.
http://www.voip-info.org/wiki/view/Asterisk+cdr+manager
HTH
--
Godson Gera,
http://godson.in
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20071201/2fb542a1/attachment.htm
More information about the asterisk-dev
mailing list