Lost Connection Error

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Reynolds
Posts: 3
Joined: Wed 22 Jul 2015 14:06

Lost Connection Error

Post by Reynolds » Wed 22 Jul 2015 14:22

Hi
I'm having trouble stopping an error message appearing.

I connect to a remote MySQL Server through Securebridge and this appears to work fine.

except a connection is left open and appears to timeout I get the "Lost Connection to MySQL server during query" error, This happens both in the IDE and Outside, having received the error the connection is re established and works fine. its just very annoying.

I have tried - LocalFailover := true
with (RetryMode := TRetryMode(rmReconnectExecute)
or RetryMode := rmReconnectExecute;

But this seems to never be called.

the code I use for connection looks like this :

if not dm3.ScSSHClient.Connected then
dm3.ScSSHClient.Connect;
dm3.MyConnection1.Connect;
DM3.Query1.Close;
DM3.Query1.ParamByName('Location_ID').Value:=LocationID;
DM3.Query1.ParamByName('FromDate').Value:=startoftheday(DateFromDte.date);
DM3.Query1.ParamByName('ToDate').Value:=endoftheday(DateToDte.date);
dm3.Query1.Prepare;
dm3.Query1.Open;

This works fine until a timeout, I would like it just to reconnect behind the scenes. If possible.

Hope you can help

David

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

Re: Lost Connection Error

Post by ViktorV » Thu 23 Jul 2015 08:46

When SecureBridge is used and TMyConnection.Options.LocalFailover is enabled, the "Lost Connection to MySQL server during query" error doesn't occur, but the OnConnectionLost event handler is called.
The sample below demonstrates correct usage of the OnConnectionLost event handler:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
  MyConnection.Options.LocalFailover := True;
  MyConnection.Connect;
end;

procedure TForm1.MyConnectionConnectionLost(Sender: TObject;
  Component: TComponent; ConnLostCause: TConnLostCause;
  var RetryMode: TRetryMode);
begin
  RetryMode := rmReconnectExecute;
end;
Please make sure you are using the OnConnectionLost event handler according to the above code. If it is so, please clarify the problem in more details.

Reynolds
Posts: 3
Joined: Wed 22 Jul 2015 14:06

Re: Lost Connection Error

Post by Reynolds » Wed 12 Aug 2015 15:28

Hi

I have tried your suggestion, but after approx. 5 min's I still get the Lost connection, I've tried to debug but it never reaches the OnLostConnection procedure of the connection.

I have it set to : RetryMode := rmReconnectExecute;
Is there another setting I must make use of?
I have tried AutoRefresh on one of the tables but that doesn't seem to help.
This is all happening outside the IDE, is there a way to suppress the message?

Regards

David

Reynolds
Posts: 3
Joined: Wed 22 Jul 2015 14:06

Re: Lost Connection Error

Post by Reynolds » Thu 13 Aug 2015 08:45

What ive done for a temp fix is rerun the query after every 2 mins with a timer.

David

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

Re: Lost Connection Error

Post by ViktorV » Thu 13 Aug 2015 10:34

Unfortunately, we can't reproduce the issue. To investigate this behavior of MyDAC, please send us a small sample to demonstrate the issue, including a script for creation and filling in the test database object. In addition, please specify the exact versions of MyDAC, SecureBridge, IDE, MySQL and SSH servers you are working with.

Post Reply