UniConnection siletly closes connection to MySQL

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Anfet
Posts: 9
Joined: Mon 26 Aug 2013 08:36

UniConnection siletly closes connection to MySQL

Post by Anfet » Wed 27 May 2015 06:07

Hi.

Recently encountered a strange error.
UniDAC with MySQL connection is closing active connection to database silently.
(Server interactive timeout = 1 day, UniConnection is specified as interactive)

After a certain period of time queries are failing with socket error.
No OnDisconnect event is fired for UniConnection.

The only way to fix it for me was to put a timer with simple poll to database. Others than that nothing works.

Any solution to that?

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: UniConnection siletly closes connection to MySQL

Post by ViktorV » Wed 27 May 2015 09:42

UniDAC can't initialize disconnection from MySQL server automatically. The BeforeDisconnect and AfterDisconnect events occur only when you explicitly disconnect from MySQL server, for example, calling the TUniConnection.Disconnect method.
You can use the TUniConnection.Ping method for checking connection to the server. If connection was lost, an error occurs and an attempt to reconnect will be performed. For example, you can call the TUniConnection.Ping method from a timer, and set the time interval less than wait_timeout of the server (in order to make intervals between commands received by the server less than the wait_timeout of the server).
You can also use the TUniConnection.OnConnectionLost event handler for error handling and an ability to reconnect to the MySQL server. See more details in the UniDAC help: http://www.devart.com/unidac/docs/#deva ... ionlost.htm

Anfet
Posts: 9
Joined: Mon 26 Aug 2013 08:36

Re: UniConnection siletly closes connection to MySQL

Post by Anfet » Wed 27 May 2015 11:05

This is exactly the error.

No events are triggered. Simply the queries are failing.
I'll check the Ping method, thank you.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: UniConnection siletly closes connection to MySQL

Post by ViktorV » Wed 27 May 2015 12:44

Feel free to contact us if you have any further questions about UniDAC.

Post Reply