Page 1 of 1

UniConnection siletly closes connection to MySQL

Posted: Wed 27 May 2015 06:07
by Anfet
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?

Re: UniConnection siletly closes connection to MySQL

Posted: Wed 27 May 2015 09:42
by ViktorV
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

Re: UniConnection siletly closes connection to MySQL

Posted: Wed 27 May 2015 11:05
by Anfet
This is exactly the error.

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

Re: UniConnection siletly closes connection to MySQL

Posted: Wed 27 May 2015 12:44
by ViktorV
Feel free to contact us if you have any further questions about UniDAC.