I had been using 'perl_exec' in my scripts with great success until I decided to try using it in the onreply_route. The strangest thing now happens; I use my perl script to write information to a database, and it seems like the failure would have to be in DBI, but it only occurs in Openser. I execute a stored procedure, and instead of doing this:
exec procedurename @arg1 = '{sip status}', @arg2 = '{callid}'
The procedure is called like this:
declare @arg2 numeric({string length}) exec procedurename @arg1 = '{sip status}', @arg2 = '{callid}' output
I have no idea where the thing is declaring @arg2 as an output variable. I can run my script manually forever and never get this message, but it happens about 50% of the time in Openser (i.e. half the time it works perfectly, without creating the output variable). I would try to run it somewhere else in my openser script, but the sip status isn't available in the request context (where I run similar scripts without any problems). The procedure is not supposed to return anything.
Here's the function I created:
***** ***** use strict; use DBI; use DBI qw(:sql_types); use OpenSER qw ( log ); use OpenSER::Constants; use OpenSER::Message;
sub proxy_onreply { my $m = shift;
my $status; my $callid;
my $sth; my $dbh; my $query;
$status = $m->getStatus(); $callid = $m->pseudoVar("$ci");
$dbh = DBI->connect("dbi:Sybase") || die "Database connection not made: $DBI::errstr";
$query = "exec procedurename @arg1 = ?, @arg1 = ?"; $sth = $dbh->prepare($query); $sth->bind_param(1, $status, SQL_VARCHAR); $sth->bind_param(2, $callid, SQL_VARCHAR);
$sth->execute;
$sth->finish; $dbh->disconnect(); } ***** *****
Any suggestions would be lovely.
Best regards,
Mik
Hi Mik,
On Friday 12 October 2007, Mik Cheez wrote:
I had been using 'perl_exec' in my scripts with great success until I decided to try using it in the onreply_route. The strangest thing now happens; I use my perl script to write information to a database, and it seems like the failure would have to be in DBI, but it only occurs in Openser.
a few weeks ago, someone else experienced problems when using DBI in OpenSER Perl scripts: http://openser.org/pipermail/users/2007-September/013388.html
We currently do not have a proper solution for the problem, as the problems are created by DBI rather than by OpenSER. You might consider trying to establish some kind of OpenSER-internal locking mechanism for the DBI functions.
Have you tried running your Perl script with only a single OpenSER instance (i.e. turning of forking)?
Bastian