How to handle lost connection
How to handle lost connection
Hi, I have an application that's running 24/7. From time to time i get a Lost connection to mysql (which is very strange to happen, server is always up and connected directly witha cross-over cable). How should I handle this problem, basically what i need is to reconnect instead of failing, but I can't go to each function and change to check connection, would there be any form for handling this from the tmyconnection ?
Thanks in advance,
J.Pieter Vos
Thanks in advance,
J.Pieter Vos
Most probably, some of your queries is executed more than 30 seconds. Try to increase a value of CommandTimeout property.
Also possible that by any connection no command was executed for a long time. In this case MySQL Server itself can break a connection. Try to execute MyConnection.Ping once at some time or increase a value of appropriate server variable.
For more details about different reasons of this error occurrence please see MySQL Reference manual http://dev.mysql.com/doc/mysql/en/gone-away.html
Also possible that by any connection no command was executed for a long time. In this case MySQL Server itself can break a connection. Try to execute MyConnection.Ping once at some time or increase a value of appropriate server variable.
For more details about different reasons of this error occurrence please see MySQL Reference manual http://dev.mysql.com/doc/mysql/en/gone-away.html
All querys take less than 1 second to execute and get back results. I also disconnect upon it's finished and then connect back again. This is a small application for wireless terminals, using sockets. I create for each socket a new thread with a connection. This morning each onnection reported a Lost COnnection to mysql. On the same machine i have another program connected to the same server that didn't faill, and i checked the server itself and it has been up all time.
Hi
I'm using direct mode only. As this application is in production and uses wireless terminals, it's for me difficult to try changes. There are max 8 terminals connected, each creates a thread with 3 tmyconnections (Two connections to same server but diferent DB, and one to another server). Normally there are 3 or 4 terminals connected, so max 4 threads, 12 connections in total. THe machine is connected directly with crossover cable to main server. All machines are big (For this app exclusive machine PIV 3 Ghz 800, 1 gb memory win 2003 server), server is dual xeon 2.8 ghz with 4 gb memory running suse 9.1). Mysql is v4.1.8 (Standart RPM official from mysql).
To main server there are about 10 workstations connected, all work with mysql and mydac never gives a connection loss.
I'm using direct mode only. As this application is in production and uses wireless terminals, it's for me difficult to try changes. There are max 8 terminals connected, each creates a thread with 3 tmyconnections (Two connections to same server but diferent DB, and one to another server). Normally there are 3 or 4 terminals connected, so max 4 threads, 12 connections in total. THe machine is connected directly with crossover cable to main server. All machines are big (For this app exclusive machine PIV 3 Ghz 800, 1 gb memory win 2003 server), server is dual xeon 2.8 ghz with 4 gb memory running suse 9.1). Mysql is v4.1.8 (Standart RPM official from mysql).
To main server there are about 10 workstations connected, all work with mysql and mydac never gives a connection loss.
We still couldn't reproduce the problem.
At the average, how many calls to different servers are performed for a second within the same application?
Are there any regularities in error happening? For example, dependence on the number of threads? In general, how often does this error happen?
If you send us small complete sample to demonstrate the problem we could solve it faster.
At the average, how many calls to different servers are performed for a second within the same application?
Are there any regularities in error happening? For example, dependence on the number of threads? In general, how often does this error happen?
If you send us small complete sample to demonstrate the problem we could solve it faster.
Handling Lost Connections
I was interested in this thread, because I am looking at a similar issue, but for different reasons!
In my case, the application is connecting to a database server across ADSL and Internet connections, and there is a real possibility of the connection being broken. It would be good to be able to trap this and retry the connection rather than expecting the user to terminate the application and restart it...
In my case, the application is connecting to a database server across ADSL and Internet connections, and there is a real possibility of the connection being broken. It would be good to be able to trap this and retry the connection rather than expecting the user to terminate the application and restart it...
-
- Posts: 451
- Joined: Wed 19 Jan 2005 09:59