View Single Post

   
  #2 (permalink)  
Old 02-28-2008, 07:07 AM
Sven Jacobs
 
Posts: n/a
Default Re: MySQL Connector .NET 1.0.6 and "Connection unexpectedly terminated" exception

> I'm having a critical problem with the MySQL Connector .NET 1.0.6. I'm
> developing a .NET (Version 1.1 SP1) application on a Windows 2000
> Professional machine with MySQL Server 4.1.14.
>
> [...]


I think I found the cause and solution to this problem! I was able to
reproduce this bug with the following small piece of C# code:

try
{
// Edit connection settings here!
MySqlConnection conn = new MySqlConnection( "server=localhost;user
id=xxx;password=yyy;database=zzz;port=3306" );
conn.Open();

// Do a SELECT on a table with many rows here!
MySqlCommand cmd = new MySqlCommand( "SELECT * FROM xyz LIMIT 1000", conn
);
MySqlDataReader reader = cmd.ExecuteReader();

while ( reader.Read() )
{
// Let's sleep for a moment. Important for reproducing the bug!
Thread.Sleep( 2400 );
}

MessageBox.Show( this, "Done" );
}
catch( Exception ex )
{
MessageBox.Show( this, ex.Message, "Exception!", MessageBoxButtons.OK,
MessageBoxIcon.Error );
}

Since the bug seems to be strongly connected to some timeout, I've tried to
manipulate several server variables which are related to timeout settings.
I found out that if the value of the variable net_write_timeout is
increased to 3600 (previously 60) the error does not occur!

For further details please see bug report at
http://bugs.mysql.com/bug.php?id=6688

--
Sincerely
Sven Jacobs
Reply With Quote