Lost connection to MySql server during query

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
starhu
Posts: 34
Joined: Thu 13 Aug 2009 12:13

Lost connection to MySql server during query

Post by starhu » Thu 20 Oct 2011 21:00

Hello,

When I connect to a remote server (a server using internet ip connection) everything is fine, but after about 10 minutes inactivity if I want to do anything with the database e.g. insert there is an error message: "Lost connection to MySql server during query"

I use Delphi 2010 and MyDac 5.90.0.59

Can you help me? Thank you

AndreyZ

Post by AndreyZ » Mon 24 Oct 2011 11:41

It seems that the value of the wait_timeout MySQL system variable is set to 10 minutes. You can find more information here:
http://dev.mysql.com/doc/refman/5.0/en/ ... it_timeout
http://dev.mysql.com/doc/refman/5.0/en/gone-away.html
You can solve the problem in two ways:
- by increasing the wait_timeout system variable value on the server;
- by using the OnConnectionLost event handler. Here is an example:

Code: Select all

procedure TMainForm.MyConnectionConnectionLost(Sender: TObject;
  Component: TComponent; ConnLostCause: TConnLostCause;
  var RetryMode: TRetryMode);
begin
  RetryMode := rmReconnectExecute;
end;
For more information, please refer to the MyDAC documentation.

starhu
Posts: 34
Joined: Thu 13 Aug 2009 12:13

Post by starhu » Mon 24 Oct 2011 19:59

Hello,

I set localFailover:=true
and

procedure TMainForm.MyConnectionConnectionLost(Sender: TObject;
Component: TComponent; ConnLostCause: TConnLostCause;
var RetryMode: TRetryMode);
begin
RetryMode := rmReconnectExecute;
end;

But the error message still pops up. It goes into the event because I also tried with a ShowMessage and it showed up .

I have no right to set the server's variable

AndreyZ

Post by AndreyZ » Tue 25 Oct 2011 11:19

We have reproduced the problem and the investigation of the problem is in progress. We will notify you when we have any results.

AndreyZ

Post by AndreyZ » Tue 25 Oct 2011 12:49

We have investigated this problem. In this case the 'Lost connection to MySQL server during query' error is an internal MyDAC error that is used for internal purposes. Such MyDAC behaviour is correct, it is caused by specificity of working with not fetched data. You will see the 'Lost connection to MySql server during query' error only if you run your application from IDE. You will not see this error when you run the executable file of your application.

EeeeEfff
Posts: 15
Joined: Wed 26 Oct 2011 00:48

Post by EeeeEfff » Thu 02 Feb 2012 00:18

I've just experienced this same problem. IDE or not, I still get a "Lost connection to MySQL server during query". Full Exception stack is below.

Error on reading data from IDataReader.
at Devart.Data.Linq.LinqCommandExecutionException.CanThrowLinqCommandExecutionException(String message, Exception e)
at Devart.Data.Linq.Provider.ObjectReader`1.MoveNext()
at System.Linq.Seq.d__20`1.MoveNext() in C:\dev\wrkspc.......:line 486
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Extract.KPIs() in C:\dev\wrkspc.................:line 162
Lost connection to MySQL server during query
at Devart.Common.aj.a(Exception A_0)
at Devart.Data.MySql.bh.a(Exception A_0)
at Devart.Common.s.e(Byte[] A_0, Int32 A_1, Int32 A_2)
at Devart.Data.MySql.bk.a(Byte[] A_0, Int32 A_1, Int32 A_2)
at Devart.Data.MySql.bk.a()
at Devart.Data.MySql.bk.b(Byte[] A_0)
at Devart.Data.MySql.u.a(Byte[] A_0)
at Devart.Data.MySql.u.a(Byte[] A_0, Boolean A_1)
at Devart.Data.MySql.an.f()
at Devart.Data.MySql.a2.b(Boolean A_0)
at Devart.Data.MySql.MySqlDataReader.a(Boolean A_0)
at Devart.Data.MySql.MySqlDataReader.System.IDisposable.Dispose()
at Devart.Common.l.a(Int32 A_0, Object A_1, Int32 A_2, Object A_3)
at Devart.Common.l.a.a(Int32 A_0, Int32 A_1, Object A_2, l A_3)
at Devart.Common.l.a(Int32 A_0, Int32 A_1, Object A_2)
at Devart.Common.DbConnectionInternal.a(Int32 A_0, Int32 A_1)
at Devart.Common.DbConnectionBase.Close()
at Devart.Data.MySql.MySqlConnection.Close()

AndreyZ

Post by AndreyZ » Thu 02 Feb 2012 09:53

You posted your question at the wrong forum. Please post your question at the following forum: http://www.devart.com/forums/viewforum.php?f=2

Post Reply