Page 1 of 1

Set CommandTimeout to resolve Mysql Has Gone Away

Posted: Fri 05 Aug 2011 10:23
by lucag
Hi,
this is my evniroment :

Delphi 2009
DbExpress Driver for Mysql 4.40

I'm connecting to db with TSqlConnection, and SimpleDataset.

In database i had a blob file of about 13 Mb.

I create connection at runtime :

Code: Select all

      ConnectionName := 'Devart MySQL Direct';
      DriverName     := 'DevartMySQLDirect';
      LibraryName    := 'dbexpmda40.dll';
      VendorLib      := 'not used';
      GetDriverFunc  := 'getSQLDriverMySQLDirect';
      LoginPrompt    := False;
      l_Conn.Params.Add('HostName='+ l_Host);
      l_Conn.Params.Add('DataBase=autoupdate');
      l_Conn.Params.Add('User_Name=' + l_User);
      l_Conn.Params.Add('Password=' + l_Password);
      l_Conn.Params.Add('CommandTimeOut=3000');
      l_Conn.Params.Add('Fetchall=False');
Then i create a query runtime and save the file blob.

All work fine in local, because query is exec in about 4 seconds, but when i'm in remote i had a Mysql Has Gone Away exactly 60 seconds after the execution of query.

I had try to read elsewhere, commandtimeout, connectiontimeout etc but i can't solve this issue.

Can you help me ?
Thank's
Luca G.
Archimedia Solutions srl

Posted: Fri 05 Aug 2011 12:30
by AndreyZ
Hello,

The connection lost problem with large blob fields is caused by MySQL server. The point is that the server can break connection if the BLOB field value is larger than max_allowed_packet. In this case you should increase max_allowed_packet on the server. You should add the following string (for example) to the my.ini file:

Code: Select all

max_allowed_packet = 20M
You can read more about this problem here:
http://dev.mysql.com/doc/refman/5.1/en/ ... ction.html
http://dev.mysql.com/doc/refman/5.1/en/ ... wed_packet

Posted: Mon 08 Aug 2011 07:15
by lucag
Hi,
i know very well mysql , i'm managing about 20 server mysql under linux and windows.

I know naturally about max_allowed_packet and he set correctly.

Infact if you read my post in local all work fine. If there is a problem about the size of blob he really don't work also in local when a query take 3-4 seconds to execute.

The real problem is the timout, after 60 seconds my query close connection.

Posted: Tue 09 Aug 2011 08:32
by AndreyZ
Please try setting the ConnectionTimeout option in the following way:

Code: Select all

l_Conn.Params.Values['ConnectionTimeout'] := '300';
, and check if the problem persists.

Posted: Tue 09 Aug 2011 09:17
by lucag
First, thank's for your reply.

i added

l_Conn.Params.Values['ConnectionTimeout'] := '300';

but nothing change. After exact 60 second the mysql has gone away.

Posted: Wed 10 Aug 2011 09:23
by AndreyZ
It seems that this problem is connected with your MySQL server and its settings, and not connected with MyDAC. Please take a look at this article: http://dev.mysql.com/doc/refman/5.0/en/gone-away.html . It may help you to find a cause of such MySQL server behaviour.

Posted: Wed 10 Aug 2011 14:25
by lucag
Thank's Again.

I'm checking however only to precise a thing :
and not connected with MyDAC
I'm not using mydac but DbExpress Driver for Mysql.

Posted: Wed 10 Aug 2011 14:42
by AndreyZ
I'm sorry, it was my mistake. I meant dbExpress driver for MySQL.