Connection unexpectedly terminated

I have a very simple SQL query statement but it needs to be run many times. I get following error randomly, maybe once per one hundred times.

MySql.Data.MySqlClient.MySqlException: Connection unexpectedly terminated.     at MySql.Data.MySqlClient.MySqlStream.LoadPacket()     at MySql.Data.MySqlClient.MySqlStream.OpenPacket()     at MySql.Data.MySqlClient.NativeDriver.Authenticate411()     at MySql.Data.MySqlClient.NativeDriver.Authenticate()     at MySql.Data.MySqlClient.NativeDriver.Open()     at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)     at MySql.Data.MySqlClient.MySqlConnection.Open()  

Following thread http://bugs.mysql.com/bug.php?id=6688 mentioned that 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!



it is talked about how to set the net_write_timeout

 [Test] public void Bug45978() { 	MySqlCommand command = OpenConnectionAndCreateCommand(); 	command.CommandText = "SET net_write_timeout = 1"; 	command.ExecuteNonQuery(); 	command.CommandText = "SELECT BlaBla FROM bigtable LIMIT 100000"; 	using (MySqlDataReader reader = command.ExecuteReader()) 	{ 		Thread.Sleep(2000); 		// after this several cycles of DataReader.Read() are executed  		// normally and then the problem, described above, occurs 		while (reader.Read()) 		{ 			object o = reader[0]; 		} 	} } 

In the last a couple of days website running, I got the above error happened for 664 times. I will set the net_write_timeout value and see whether the condition gets better.

Comments

Popular posts from this blog

Javascript Hosted on Google Drive Not Working Reliably

Newsmag Theme and External Featured Image

Responsive Web Design