ConnectionTimeout doesn't work

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
GEswin
Posts: 186
Joined: Wed 03 Nov 2004 16:57
Location: Spain
Contact:

ConnectionTimeout doesn't work

Post by GEswin » Thu 30 Dec 2004 21:32

I'm in a case that I wan't to try to connect to a remote server, but if I can't in 1 or 2 seconds, then connect to a local server. I changed the ConnectionTimeout propertie, but it's always 15 seconds, whatever I set.

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Re: ConnectionTimeout doesn't work

Post by Ikar » Fri 31 Dec 2004 07:37

Please specify what exact MyDAC version you use (3.XX.X.XX).

GEswin
Posts: 186
Joined: Wed 03 Nov 2004 16:57
Location: Spain
Contact:

Post by GEswin » Tue 04 Jan 2005 11:25

I tried both with 3.00.1.4 and 3.30.1.13, and both fail. The connections times out after 15 seconds and not at the time set.

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Tue 04 Jan 2005 12:09

Please try 3.30.2.15

GEswin
Posts: 186
Joined: Wed 03 Nov 2004 16:57
Location: Spain
Contact:

Post by GEswin » Wed 05 Jan 2005 14:04

Well, just upgraded to 3.30.2.15 (D7) and still doens't work. I set for example 2 seconds on ConnectionTimeout, and still waits 15 seconds.

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Thu 06 Jan 2005 10:32

We carefully checked possible reasons of this behaviour. The problem is in impossibility to set timeout for some WinSock functions - gethostbyname and connect.

As a solution we can advise you the next variants:
1) Establish a connection at the separated thread.
2) Before calling TMyConnection.Connect, execute ping for a specified server. If ping is succeeded (host is available), in this case a connect (reject in connection) happens quickly.

GEswin
Posts: 186
Joined: Wed 03 Nov 2004 16:57
Location: Spain
Contact:

Post by GEswin » Mon 10 Jan 2005 14:54

Thanks Ikar for the tip. I've done this, and improved a lot my problem, which was specifing to connect to movile computers, which lose/reconnect and change their IP lot of times during the day. Now I have a quick metod to try to connect. If after 1 seg ping fails, then I don't connect, but just show mirrored information.

Post Reply