Delphi 7 - Lost connection (timeout)

Forum related to MySQL

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
Scouz
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 15.12.2005, 10:16

Delphi 7 - Lost connection (timeout)

Post by Scouz »

Anyone who knows how to make persistent connections with the zeos db components for Delphi 7?
Everything works fine with queries, except that the connection times out/dies after about 8-10 seconds. Any workaround for this?
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post by zippo »

?

Can you explain more detailed? I use Zeos for last few years and never had this problem. you mean that you connect, do a query and it disconnects after 8 secs after the query opens? It seems a network problem...
NTO
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 03.01.2006, 16:29

Post by NTO »

I have a sort like problem.
Is winxp sp2 installed on this system ?
if the build-in firewall is activated there's a maximum of 10 connections for 1 app. Because I do loads of query's within a couple of seconds my program gets very slow or sometimes trows messages like " Mysql Lost connection (timeout)"

anyone a solution

Nico
anse123
Junior Boarder
Junior Boarder
Posts: 26
Joined: 23.02.2006, 22:28

Post by anse123 »

hi,

in my experiance this is a general issue with the mysql-server, which cuts off connections if they are idle for a specific time and other clients are waiting to get a connection. You have to know that the server only allows a specific amount of connections from all clients, which is by default at 100 I think. So fx if you have the 70's connection to the server, there can also come up to 30 additional connections without any interference. If then come even more clients requesting a connection, the server has to decide what to do: block each new connection as long as noone of the 100 hasn't closed the connection or have a look at idle connections from the 100 and throw them away. The last behaviour can be seen on many servers.

The good thing is that you get automatically re-connected with almost all connection parameters without being prompted again for username or so. In ZeosLib I only find it hard to restore the last Database-property - I always get these issues in this order:

1. login with your ZConnection and fire: "USE dbname1"
2. be idle for a specific amount of seconds/minutes
3. fire some sql on a table
4. SQL error: "Lost connection to mysql server"
5. automatically getting re-connected
6. fire some sql-statement like "select * from sometable"
7. SQL error: "No database selected"

The last error is quite logical, as only the connection gets restored, but not the last used database. But it's a big question how to avoid this last query? There is no fired event of ZConnection which indicates the re-connection, I tried all these: BeforeConnect, BeforeDisconnect, AfterConnect, AfterDisconnect, OnLogin - not one of these is fired in a case of re-connection, so it's impossible to react internally on the disconnect. Anyone has an idea?

Greetings,
Anse

P.S.: HeidiSQL 3.0 RC1 will be released this week!
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post by zippo »

Yupieeeee!

About connection lost - you can tweak the parameters on MySQL server. I can't remember the parameters names, but if you need it i'll search.

About anse123 problem. I think the reconnection is based on the properties of the component. Try to check in which database you're in before doing the 6. point on the list.
anse123
Junior Boarder
Junior Boarder
Posts: 26
Joined: 23.02.2006, 22:28

Post by anse123 »

OK, sounds quite easy :) Will try it this evening and let you know if it works.

Anse
NTO
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 03.01.2006, 16:29

Post by NTO »

If the mysql is installed on an winxp-sp2 machine it allows only 10 incoming connections (this isn't an issue of the mysql, but pure from winxp).
If i run my program localhost only, it works great.

On google there are many tweaks to find for this winxp-sp2 problem, but none seems to work for me.
( http://www.speedguide.net/read_articles.php?id=1497 )


Passing the Zconnection between several application-files (exe, dll, dll, etc etc) would be a solution for me.

But zeos starts to trow vage av's when I try to do that.
(probably because of : http://seegernet.koolhost.de/zeosforum/ ... .php?t=429 )
bravecobra
Junior Boarder
Junior Boarder
Posts: 29
Joined: 31.10.2005, 00:09
Location: Antwerp
Contact:

Post by bravecobra »

zippo wrote:Yupieeeee!

About connection lost - you can tweak the parameters on MySQL server. I can't remember the parameters names, but if you need it i'll search.

About anse123 problem. I think the reconnection is based on the properties of the component. Try to check in which database you're in before doing the 6. point on the list.
Could you specify me the parameters? I'm experiencing the same problem.
Post Reply