MySQL连接错误太多

时间:2015-05-11 12:31:38

标签: c# mysql database network-programming database-connection

我有一个C#应用程序,它在LAN计算机上作为客户端运行,并访问服务器上的MySQL数据库。在我的测试环境中,应用程序正在运行,没有任何问题。

但是,由于某种原因,在客户端的某个地方有间歇性的MySQL连接被终止或超时。我遇到了这样的错误:

  

无法从传输连接读取数据:连接尝试失败,因为连接方未正确响应   一段时间后或连接主机无法响应。

超时IO

注意:我没有更改默认连接Timeout。获取的数据只是几条记录,没什么大的。

其中一台计算机遇到如此多的错误,被MySQL阻止,必须刷新主机并增加连接错误限制,以免再次发生。

对我而言,这似乎是一个局域网网络问题,但我是新手,所以如果你能就我应该如何进一步提供建议,那就太棒了?是否有任何工具可用于监控此连接错误发生的原因?

注意:此外,服务器错误日志中没有任何内容。当只有6台PC运行这个应用程序时,只有3天就有339个中止连接。

此外,stackstrace显示这些是套接字异常。

编辑:我正在添加堆栈跟踪以获取更多信息。

System.TimeoutException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. 
---> System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. 
---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at MySql.Data.Common.MyNetworkStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   --- End of inner exception stack trace ---
   at MySql.Data.Common.MyNetworkStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at MySql.Data.MySqlClient.TimedStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count)
   at MySql.Data.MySqlClient.MySqlStream.ReadFully(Stream stream, Byte[] buffer, Int32 offset, Int32 count)
   at MySql.Data.MySqlClient.MySqlStream.LoadPacket()
   at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.ReadPacket()
   at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.Authenticate(Boolean reset)
   at MySql.Data.MySqlClient.NativeDriver.Authenticate(String authMethod, Boolean reset)
   at MySql.Data.MySqlClient.NativeDriver.Open()
   at MySql.Data.MySqlClient.Driver.Open()
   at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
   at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
   at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
   at MySql.Data.MySqlClient.MySqlPool.GetConnection()
   at MySql.Data.MySqlClient.MySqlConnection.Open() 

0 个答案:

没有答案