SQL Server 2012远程连接给出Timeout和ASYNC_NETWORK_IO错误

时间:2013-05-21 16:10:56

标签: .net sql-server networking sql-server-2012 tcp-ip

我遇到连接到SQL Server 2012远程实例的服务的问题。

.NET 2.0服务在客户端计算机上运行,​​它使用TCP / IP连接到当前运行SQL Server 2012实例的远程Web服务器。该Web服务器曾经是Windows Server 2003和SQL Server 2005以及6个月前升级没有任何问题。然后,该服务检查是否有任何需要下载的数据。

客户端计算机

  • Windows Server 2003

Web服务器

  • Windows Server 2012
  • SQL Server 2012

直到上周五它突然停止工作并且它给出以下错误日志消息

这个运行正常5年以上
Event Type: Warning
Event Source:   
Event Category: None
Event ID:   0
Date:       21/05/2013
Time:       16:45:11
User:       N/A
Computer:   
Description:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error)
   at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket()
   at System.Data.SqlClient.TdsParserStateObject.ReadByteArray(Byte[] buff, Int32 offset, Int32 len)
   at System.Data.SqlClient.TdsParserStateObject.ReadUInt32()
   at System.Data.SqlClient.TdsParser.ReadSqlValueInternal(SqlBuffer value, Byte tdsType, Int32 typeId, Int32 length, TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.ReadSqlValue(SqlBuffer value, SqlMetaDataPriv md, Int32 length, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.ReadColumnData()
   at System.Data.SqlClient.SqlDataReader.ReadColumnHeader(Int32 i)
   at System.Data.SqlClient.SqlDataReader.ReadColumn(Int32 i, Boolean setTimeout)
   at System.Data.SqlClient.SqlDataReader.GetValueInternal(Int32 i)
   at System.Data.SqlClient.SqlDataReader.GetValue(Int32 i)
   at RedBlack.Data.Synchronisation.SyncManager.UpsertRecords(String sourceSelect, String destTable, String[] destFields, List`1 relations)
   at General.CyPro.Application.WebSynchronisation.SyncRoutines.FetchOrders(UpsertFlags upsertOptions)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at RedBlack.CyPro.Application.WebSynchronisation.Job.Run(Object[] args)
...
System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error)
   at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket()
   at System.Data.SqlClient.TdsParserStateObject.ReadByteArray(Byte[] buff, Int32 offset, Int32 len)
   at System.Data.SqlClient.TdsParserStateObject.ReadUInt32()
   at System.Data.SqlClient.TdsParser.ReadSqlValueInternal(SqlBuffer value, Byte tdsType, Int32 typeId, Int32 length, TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.ReadSqlValue(SqlBuffer value, SqlMetaDataPriv md, Int32 length, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.ReadColumnData()
   at System.Data.SqlClient.SqlDataReader.ReadColumnHeader(Int32 i)
   at System.Data.SqlClient.SqlDataReader.ReadColumn(Int32 i, Boolean setTimeout)
   at System.Data.SqlClient.SqlDataReader.GetValueInternal(Int32 i)
   at System.Data.SqlClient.SqlDataReader.GetValue(Int32 i)
   at RedBlack.Data.Synchronisation.SyncManager.UpsertRecords(String sourceSelect, String destTable, String[] destFields, List`1 relations)
   at General.CyPro.Application.WebSynchronisation.SyncRoutines.FetchOrders(UpsertFlags upsertOptions)

我已检查过网络服务器上的活动监视器,当查询运行时,它会被WAIT_TYPE ASYNC_NETWORK_IO暂停。

我已经运行查询,它试图在远程连接到Web服务器实例的客户端服务器上的Management Studio中手动运行它运行大约40秒,返回2600+行,然后它给出了以下错误

Msg 121, Level 20, State 0, Line 0
A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.)

我在Management Studio中的计算机上运行相同的查询,远程连接到Web服务器实例,并在0.312秒内返回完整的4000行。

我无法想象这一点,因为在我看来,这是一种网络问题。客户硬件技术人员检查了网络,并表示他们所关心的一切都很好。

如果您需要更多信息,请告诉我

由于

3 个答案:

答案 0 :(得分:3)

这已经解决了,问题最终成了客户互联网的问题。我没有所有的细节,但BT在交易所发现了一个问题,一旦修复了,程序就开始重新运作了。

答案 1 :(得分:2)

这是值得一试的。 Here is an article on MSDN Blog表明了两件事:

Long running task or uncommited transaction

30秒是SQL客户端要等待的默认值。它使您的客户端计算机超时。 可能是您的客户端此连接的实际数据传输速度太慢,无法及时获取所有行? 也许另一个进程关闭此连接,客户端等待响应?

答案 2 :(得分:2)

从其他有(类似)类似问题的人的决议来看,这几乎总是成为三件事之一:

  1. 磁盘损坏或失败。使用CHKDSK /r解决此问题。

  2. 网卡错误,或

  3. DHCP问题,尤其是租约过期/续订。

  4. 我不知道任何特定于SQL Server的情况。