VoIP Mailing List Archives
Mailing list archives for the VoIP community |
|
View previous topic :: View next topic |
Author |
Message |
dk at donkelly.biz Guest
|
Posted: Tue Dec 03, 2013 9:41 am Post subject: [asterisk-users] link to MySQL connection |
|
|
I’m making changes to an Asterisk IVR designed by someone else.
The application uses both func_odbc.conf and php agi to access an external MySQL database.
In the php routines, I would like to use the persistent connection that is established in the dialplan, rather than creating a new connection each time they run. How can I do this?
In res_odbc.conf, the context “asterisk” is established, successfully referencing “asterisk-connector” in odbc.ini.
pre-connect => yes resulting in a persistent connection at startup.
Opening a connection in the php routines takes about 5 seconds, which is unacceptable.
--Don |
|
Back to top |
|
|
jcolp at digium.com Guest
|
Posted: Tue Dec 03, 2013 9:42 am Post subject: [asterisk-users] link to MySQL connection |
|
|
Don Kelly wrote:
Quote: | I’m making changes to an Asterisk IVR designed by someone else.
The application uses both func_odbc.conf and php agi to access an
external MySQL database.
In the php routines, I would like to use the persistent connection that
is established in the dialplan, rather than creating a new connection
each time they run. How can I do this?
|
You can't, they are completely separate processes and code.
--
Joshua Colp
Digium, Inc. | Senior Software Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: www.digium.com & www.asterisk.org
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users |
|
Back to top |
|
|
dk at donkelly.biz Guest
|
Posted: Tue Dec 03, 2013 9:50 am Post subject: [asterisk-users] link to MySQL connection |
|
|
Quote: | In the php routines, I would like to use the persistent connection
that is established in the dialplan, rather than creating a new
connection each time they run. How can I do this?
|
You can't, they are completely separate processes and code.
Joshua Colp
Thanks--that's not the answer I wanted, but it sure was quick.
Is there anything that would enable me to use a persistent connection in the
agi?
--Don
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users |
|
Back to top |
|
|
EWieling at nyigc.com Guest
|
Posted: Tue Dec 03, 2013 9:53 am Post subject: [asterisk-users] link to MySQL connection |
|
|
Yes. Use func_odbc in your PHP AGI. In Asterisk dialplan functions are treated like dialplan variables so you can get and set them just like you would other dialplan variables.
If it takes 5 seconds to open a PDO DB connection inside PHP you have some OTHER problem.
-----Original Message-----
From: asterisk-users-bounces@lists.digium.com [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Don Kelly
Sent: Tuesday, December 03, 2013 9:50 AM
To: 'Asterisk Users Mailing List - Non-Commercial Discussion'
Subject: Re: [asterisk-users] link to MySQL connection
Quote: | In the php routines, I would like to use the persistent connection
that is established in the dialplan, rather than creating a new
connection each time they run. How can I do this?
|
You can't, they are completely separate processes and code.
Joshua Colp
Thanks--that's not the answer I wanted, but it sure was quick. Is there anything that would enable me to use a persistent connection in the agi?
--Don
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users |
|
Back to top |
|
|
webaccounts at jgoettg... Guest
|
Posted: Tue Dec 03, 2013 10:01 am Post subject: [asterisk-users] link to MySQL connection |
|
|
Then you should analyze why it takes 5s. Opening and closing a mysql connection should take at
most a fraction of a second on a local net.
BTW, classical web sites (plain PHP and HTML) do not maintain state, so keeping the mysql
connection open may not be at all possible. I forgot whether open db connections get closed
automatically after the web page has been rendered, but I think so. You could test this.
For data processing you do not want to got through Asterisk. You could actually write your own
db proxy, but I still think it makes more sense to find out why opening the db connection takes
so much time.
jg
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users |
|
Back to top |
|
|
dk at donkelly.biz Guest
|
Posted: Tue Dec 03, 2013 10:10 am Post subject: [asterisk-users] link to MySQL connection |
|
|
Then you should analyze why it takes 5s. Opening and closing a mysql
connection should take at most a fraction of a second on a local net.
BTW, classical web sites (plain PHP and HTML) do not maintain state, so
keeping the mysql connection open may not be at all possible. I forgot
whether open db connections get closed automatically after the web page has
been rendered, but I think so. You could test this.
For data processing you do not want to got through Asterisk. You could
actually write your own db proxy, but I still think it makes more sense to
find out why opening the db connection takes so much time.
jg
I'll look into why the connection takes so long.
I'm looking for a quick fix for the problem
Long term, I think a web service would be better for what this routine is
doing. It doesn't do any telephony stuff and only requires one variable from
the dialplan.
--Don
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to
Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users |
|
Back to top |
|
|
dk at donkelly.biz Guest
|
Posted: Tue Dec 03, 2013 10:14 am Post subject: [asterisk-users] link to MySQL connection |
|
|
Quote: | In the php routines, I would like to use the persistent connection
that is established in the dialplan, rather than creating a new
connection each time they run. How can I do this?
|
You can't, they are completely separate processes and code.
Joshua Colp
Thanks--that's not the answer I wanted, but it sure was quick. Is there
anything that would enable me to use a persistent connection in the agi?
--Don
Yes. Use func_odbc in your PHP AGI. In Asterisk dialplan functions are
treated like dialplan variables so you can get and set them just like you
would other dialplan variables.
If it takes 5 seconds to open a PDO DB connection inside PHP you have some
OTHER problem.
Eric Wieling
Thanks, Eric. If I can't figure out why the connection takes so long, I'll
try the func_ODBC approach.
--Don
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users |
|
Back to top |
|
|
asterisk.org at sedwar... Guest
|
Posted: Tue Dec 03, 2013 12:50 pm Post subject: [asterisk-users] link to MySQL connection |
|
|
On Tue, 3 Dec 2013, Don Kelly wrote:
Quote: | Opening a connection in the php routines takes about 5 seconds, which is
unacceptable.
|
One of my AGIs (written in C) reads 3 arguments from the command line,
gets 4 channel variables, reads a row from the database, and sets 3
channel variables.
On an AMD Athlon BE-2300 (a pretty low end processor), CentOS 4.9,
Asterisk 1.2.37, MySQL 5.0.95 running on a separate host; 1,000 executions
of this AGI takes about 16 seconds or about 0.016 seconds for a single
execution. (60 per second.)
On a VirtualBox VM (2 cores) on an Intel i7-3770, CentOS 5.9, Asterisk
1.2.40, MySQL 5.0.95 running on the same VM, 25,000 executions takes about
40 seconds or about 0.0016 seconds for a single execution. (625 per
second.)
Why does your AGI take 5 seconds?
--
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards sedwards@sedwards.com Voice: +1-760-468-3867 PST
Newline Fax: +1-760-731-3000
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users |
|
Back to top |
|
|
james at fivecats.org Guest
|
Posted: Tue Dec 03, 2013 1:52 pm Post subject: [asterisk-users] link to MySQL connection |
|
|
On 12/3/2013 10:11 AM, Don Kelly wrote:
Quote: |
Quote: | In the php routines, I would like to use the persistent connection
that is established in the dialplan, rather than creating a new
connection each time they run. How can I do this?
|
You can't, they are completely separate processes and code.
Joshua Colp
Thanks--that's not the answer I wanted, but it sure was quick. Is there
anything that would enable me to use a persistent connection in the agi?
--Don
Yes. Use func_odbc in your PHP AGI. In Asterisk dialplan functions are
treated like dialplan variables so you can get and set them just like you
would other dialplan variables.
If it takes 5 seconds to open a PDO DB connection inside PHP you have some
OTHER problem.
Eric Wieling
Thanks, Eric. If I can't figure out why the connection takes so long, I'll
try the func_ODBC approach.
|
look into DNS problems. Something may be trying to do an reverse DNS
lookup and taking too long to either give up or get an answer.
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users |
|
Back to top |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|