From: Hans on 27 Mar 2010 03:38 Hi, my tcl application use mysqltcl to connect to mysql server. command is like below: set db_handle [::mysql::connect -host $DB_SERVER -user $DB_USER - password $DB_PASS -db $DB_NAME -foundrows 1] For security reason, now I put a firewall between my pc and mysql server, then I found firewall will disconnect my mysql session after some time. then I have to detect error and reestablish the connection. My question is: Is there an easy way to setup keepalive for that session? like, is there an option to enable session keepalive and then the client can send keepalive or any other packets to the server periodically? then the connection will not be shutdown and always be available. Thanks a lot Hans Yin
From: tomk on 28 Mar 2010 14:01 On Mar 27, 12:38 am, Hans <hans...(a)gmail.com> wrote: > Hi, > my tcl application use mysqltcl to connect to mysql server. command is > like below: > > set db_handle [::mysql::connect -host $DB_SERVER -user $DB_USER - > password $DB_PASS -db $DB_NAME -foundrows 1] > > For security reason, now I put a firewall between my pc and mysql > server, then I found firewall will disconnect my mysql session after > some time. then I have to detect error and reestablish the > connection. > > My question is: Is there an easy way to setup keepalive for that > session? like, is there an option to enable session keepalive and > then the client can send keepalive or any other packets to the server > periodically? then the connection will not be shutdown and always be > available. > > Thanks a lot > > Hans Yin This probably isn't what you want to hear but it sounds to me like you're system architecture isn't correct for the problems you are trying to solve. Database servers don't support session management, web servers are generally used for that problem. If you want session management and a database then connect your database to a web server behind your firewall and talk to the web server with your application (through the firewall). If you configure the web server correctly it will keep a pool of database connections alive for use by the web server sessions. Tom K.
From: Hans on 30 Mar 2010 00:55 On Mar 29, 2:01 am, tomk <krehbiel....(a)gmail.com> wrote: > On Mar 27, 12:38 am, Hans <hans...(a)gmail.com> wrote: > > > > > Hi, > > my tcl application usemysqltclto connect to mysql server. command is > > like below: > > > set db_handle [::mysql::connect -host $DB_SERVER -user $DB_USER - > > password $DB_PASS -db $DB_NAME -foundrows 1] > > > For security reason, now I put a firewall between my pc and mysql > > server, then I found firewall will disconnect my mysql session after > > some time. then I have to detect error and reestablish the > > connection. > > > My question is: Is there an easy way to setup keepalive for that > > session? like, is there an option to enable session keepalive and > > then the client can send keepalive or any other packets to the server > > periodically? then the connection will not be shutdown and always be > > available. > > > Thanks a lot > > > Hans Yin > > This probably isn't what you want to hear but it sounds to me like > you're system architecture isn't correct for the problems you are > trying to solve. Database servers don't support session management, > web servers are generally used for that problem. If you want session > management and a database then connect your database to a web server > behind your firewall and talk to the web server with your application > (through the firewall). If you configure the web server correctly it > willkeepa pool of database connectionsalivefor use by the web > server sessions. > > Tom K. thanks for the response. I understand your meaning, in my case, I did not use web server, my client connect to mysql database server directly(by mysqltcl), so its role is just like the web server. so we can change my question to: if there is a firewall between web server and database server, webserver will establish a connection to database server. how can we keepalive this connection if no query for a long time? I understand we can send database ping from webserver periodicly, maybe that's just what you suggested. Is there an easier way? like setup an option in my.cnf or just an option in "Connect" command? Thanks a lot.
From: tomk on 30 Mar 2010 13:46 Did you try the ::mysql::ping command? Create a reconnect proc and call it before every mysql command in your application. tomk > I understand your meaning, in my case, I did not use web server, my > client connect to mysql database server directly(by mysqltcl), so its > role is just like the web server. so we can change my question to: if > there is a firewall between web server and database server, webserver > will establish a connection to database server. how can we keepalive > this connection if no query for a long time? > > I understand we can send database ping from webserver periodicly, > maybe that's just what you suggested. Is there an easier way? like > setup an option in my.cnf or just an option in "Connect" command?
|
Pages: 1 Prev: tcl Developer positions in Arlington, VA! Next: linkstaterouting algorithm |