[Home]

Summary:ASTERISK-05476: DB Connection in AGI
Reporter:Lawrence (finejava)Labels:
Date Opened:2005-11-06 13:13:05.000-0600Date Closed:2011-06-07 14:10:43
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Resources/res_agi
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:Hi,

I've found a bug in realtime which is quite severe to me...all this while i'm running *-1.0.9 very well as my billing engine...but when i upgraded to *-1.2.0 regardless of version beta 1/2, i keep on losing db connection which means missing cdrs and the calls are not charged...my agi scripts are written in perl
Comments:By: Lawrence (finejava) 2005-11-06 13:14:50.000-0600

Marshall can u pls change this category to AGI...sorry for the mistakes...10q

By: Kevin P. Fleming (kpfleming) 2005-11-07 19:35:35.000-0600

AGI does not use database connections.

Without a more accurate description of the problem, including complete console traces, there is very little anyone will be able to do to help you get this problem fixed.

By: Lawrence (finejava) 2005-11-07 23:34:20.000-0600

sorry for the brief description...
i'm using starsshops billing engine which uses perl AGI script...in the script it uses perl DBI package to connect to mysql...i came to know bout * realtime so what i do is upgrade my current *-1.0.9 to *-1.2.0-beta1 & beta2. but it is giving problem writing the cdrs into the db after the calls and also updating the card inuse. when i revert back to 1.0.9 the problem is solve...and it's been working fine with 1.0.9 all this while...the script is exactly the same...i was suspecting something to do with the * AGI modules...as it works perfectly with 1.0.9 and below but with 1.2.0 it keeps on giving db connection problems

By: Kevin P. Fleming (kpfleming) 2005-11-07 23:44:12.000-0600

I would suggest trying to simplify your configuration as much as possible while still being able to reproduce the problem; we don't have access to any of that external code (nor do we have time to figure out how it works), so if you can reproduce the problem with only a simple configuration we'll have a much better chance of finding the problem.

Can I assume that you completely wiped out your /usr/lib/asterisk/modules directory each time you made these version changes? You can't leave _any_ old modules in there and expect things to work properly.

By: Lawrence (finejava) 2005-11-08 00:42:47.000-0600

yes...it was a clean install of *-1.2.0

below are my configuration:
sip.conf
[general]
port=5060                       ; UDP Port to bind to (SIP standard port is 5060)
bindaddr=0.0.0.0                ; IP address to bind to (0.0.0.0 binds to all)
tos=reliability                   ; lowdelay,throughput,reliability,mincost,none
defaultexpirey=600             ; Default length of incoming/outoing registration
maxexpirey=3600
rtptimeout=60
rtpholdtimeout=300
useragent=SoftSwitch
realm=voip
dtmfmode=rfc2833
nat=yes

disallow=all
allow=g729

[xchange1004]
type=friend
username=xchange1004
secret=superjaring
host=dynamic
context=prepaid
nat=yes
canreinvite=no
disallow=all
allow=g729
qualify=yes

extensions.conf
exten => _00XXXXXXXX.,1,DeadAGI(postpaidnoivr.agi,${CALLERIDNAME},${EXTEN:2})
exten => _00XXXXXXXX.,2,Hangup

postpaidnoivr.agi (code snippets)
#!/usr/bin/perl

use DBI;
use Asterisk::AGI;

sub connect_db() {
       my $dsn = "DBI:mysql:database=callingcard;host=XXX.XXX.XXX.XXX";
       $dbh = DBI->connect($dsn, 'XXX', 'XXX');
}

sub close_db(){
       $dbh->disconnect if $dbh;
}

sub savecdr() {
       my ($cardnum, $callerid, $callednum, $trunk, $disposition, $billseconds, $billcost,$callstart) = @_;
       if(!$dbh) {
               &connect_db();
       }
       $dbh->do("INSERT INTO cdrs (cardnum,callerid,callednum,trunk,disposition,billseconds,billcost,callstart) VALUES (" .
               $dbh->quote($cardnum) . ", " . $dbh->quote($callerid) . ", " . $dbh->quote($callednum) . ", " . $dbh->quote($trunk) . ", " .
               $dbh->quote($disposition) . ", " . $dbh->quote($billseconds) . ", " . $dbh->quote($billcost) . ", " . $dbh->quote($callstart) . ")");
}



By: Lawrence (finejava) 2005-11-08 19:20:02.000-0600

And another finding is that...i can't seems to pass in ${CALLERIDNUM} or ${CALLERIDNAME} into the AGI...the only way to solve that is by SetVar then only it is successful passed in as reported in issue 0005591 in *-1.2.0-beta1

By: Mark Spencer (markster) 2005-11-12 19:55:37.000-0600

They're separated into two parameters, agi_callerid and agi_calleridname in 1.2, and also you might check the SIGHUP changes (see UPGRADE.txt) with respect with your AGI issue.

By: Digium Subversion (svnbot) 2008-01-15 15:55:58.000-0600

Repository: asterisk
Revision: 7091

U   trunk/UPGRADE.txt

------------------------------------------------------------------------
r7091 | markster | 2008-01-15 15:55:58 -0600 (Tue, 15 Jan 2008) | 2 lines

Mention callerid name / num changes in UPGRADE.txt (bug ASTERISK-5476)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=7091