Page 1 of 1

Connection timeout reason

Posted: Thu 02 May 2013 10:09
by jmuehlenhoff
Hi,

I have been wondering why connections to MySQL get closed after some period of idle time.

Is this due to some timeout setting on the MySQL server?

What is the best way to handle a "timeout based" disconnect? I know there is a OnConnectionLost event, but documentation is rather scarce on this subject.

Best regards.

Re: Connection timeout reason

Posted: Fri 10 May 2013 09:09
by DemetrionQ
Hello.

There is a MySQL system variable - wait_timeout - it determines the number of seconds the server waits for activity on a noninteractive connection before closing it
http://dev.mysql.com/doc/refman/5.0/en/ ... it_timeout

To process connection lost you can handle the TMyConnection.OnConnectionLost event.
For that you should set the TMyConnection.Options.LocalFailover option to True.
TMyConnection.OnConnectionLost event handler has the RetryMode parameter that defines the behaviour after connection lost.

The additional information about using the OnConnectionLost event handler can be found in the article "Working in an Unstable Network" of the MyDAC documentation. Also you can find the description of the LocalFailover property, the OnConnectionLost event and the TRetryMode enumeration in the MyDAC documentation.

Also you can look at the example of handling the OnConnectionLost event in the Miscellaneous\FailOver demo.

Re: Connection timeout reason

Posted: Fri 10 May 2013 09:14
by jmuehlenhoff
Thank you, that's going to be helpful.

Re: Connection timeout reason

Posted: Tue 14 May 2013 10:38
by DemetrionQ
If any other questions come up, please contact us.