Page 1 of 1
How to handle lost connection
Posted: Tue 01 Feb 2005 09:24
by GEswin
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
Posted: Tue 01 Feb 2005 10:46
by Ikar
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
Posted: Tue 01 Feb 2005 14:47
by GEswin
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.
Posted: Wed 02 Feb 2005 08:23
by Ikar
What MyDAC version do you use? Do you use ConnectionPooling?
Posted: Wed 02 Feb 2005 09:12
by GEswin
Latest version, and I don't use pooling.
Posted: Wed 02 Feb 2005 10:59
by Ikar
Do you use Direct mode or libmysql.dll? If the last one, what is its version?
Please specify if the occurrence of the error changes if to change TMyConnection.Options.Direct.
How many, roughly, queries are performed in a second within the same application? How many threads are used MyDAC on it?
Posted: Thu 03 Feb 2005 13:34
by GEswin
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.
Posted: Fri 04 Feb 2005 07:35
by Ikar
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.
Handling Lost Connections
Posted: Wed 14 Sep 2005 16:35
by Guest
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...
Posted: Wed 14 Sep 2005 21:29
by GEswin
Enclose the functions in Try..Except and best issues i've seen if it's some process you've to do from time to time, is just connect/do_the_job/disconnect. Right now i'm very happy and got no problems with mydac, and i have many appz working over adsl too.
Posted: Thu 15 Sep 2005 08:17
by Ikar
We think about MyDAC development in this direction. As a temporary
solution you can use MyDAC with MIDAS
Posted: Fri 16 Sep 2005 06:15
by swierzbicki
I did the same. It works like a charm.
Enclose the functions in Try..Except