Hi,
after the network was interrupted for a moment, appears in certain situations, the following error message:
Assertion failure (D:\Projects\Delphi\Dac\MySql\Source\MySqlApiDirect.pas, Zeile 580
What can I do, or what is said from the Assert?
Delphi 2009, MySQL, newest version of VCL UniDAC.
Thanks, André
MySQL: Assertion failure after network reconnect
-
AndreyZ
Re: MySQL: Assertion failure after network reconnect
Hello,
This problem can be caused by incorrect working with threads. The right way to work in a multi-threaded application is to have connection (the TMyConnection component) in each thread. Please check that you have one connection in each thread.
This problem can be caused by incorrect working with threads. The right way to work in a multi-threaded application is to have connection (the TMyConnection component) in each thread. Please check that you have one connection in each thread.
Re: MySQL: Assertion failure after network reconnect
Hi,
every thread has it's own connection. Normally everything works fine.
For connecting the MySQL-Server a SSH-Tunnel is used. Sometimes this tunnel disconnects when it has to be open.
My resolution: If I open a query I handle every connection-exception and try to reopen the SSH-Tunnel. After this I open the Query again. This worked already, perhaps with an older Version of UniDAC.
Now I get this assert when I try to Open the Query again. I already tried to do a disconnect when the error occurs, but this doesn't help.
Thx André
every thread has it's own connection. Normally everything works fine.
For connecting the MySQL-Server a SSH-Tunnel is used. Sometimes this tunnel disconnects when it has to be open.
My resolution: If I open a query I handle every connection-exception and try to reopen the SSH-Tunnel. After this I open the Query again. This worked already, perhaps with an older Version of UniDAC.
Now I get this assert when I try to Open the Query again. I already tried to do a disconnect when the error occurs, but this doesn't help.
Thx André
-
AndreyZ
Re: MySQL: Assertion failure after network reconnect
To resume lost connection, you should use the TMyConnection.OnConnectionLost event handler. The OnConnectionLost event handler is used to process fatal errors and perform failover. To make the OnConnectionLost event handler work, you should set the TMyConnection.Options.LocalFailover property to True. Note that to use the OnConnectionLost event handler, you should add the MemData unit to the USES clause of your unit. Here is an example of using the OnConnectionLost event handler:In this case, if connection was lost, MyDAC will try to reconnect and reexecute the abortive operation. Please check if this approach solves the problem.
Code: Select all
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
MyConnection1.Options.LocalFailover := True;
MyConnection1.Open;
end;
procedure TForm1.MyConnection1ConnectionLost(Sender: TObject;
Component: TComponent; ConnLostCause: TConnLostCause;
var RetryMode: TRetryMode);
begin
RetryMode := rmReconnectExecute;
end;