【问题标题】:The wait operation timed out Win32Exception (0x80004005): The wait operation timed out azure等待操作超时 Win32Exception (0x80004005):等待操作超时 azure
【发布时间】:2015-02-02 04:10:32
【问题描述】:

从 sql azure 检索大量数据时出现以下错误。我已经实现了瞬态故障处理,但仍然出现此错误

说明:在执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息:System.ComponentModel.Win32Exception:等待操作超时

来源错误:

在执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常起源和位置的信息。

堆栈跟踪:

[Win32Exception (0x80004005): 等待操作超时]

[SqlException (0x80131904): 超时。在操作完成之前超时时间已过或服务器没有响应。] System.Data.SqlClient.SqlConnection.OnError(SqlException异常,布尔breakConnection,Action1 wrapCloseInAction) +1789270 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)+5340622 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj,布尔调用者HasConnectionLock,布尔异步关闭)+244 System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +1691 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,RunBehavior runBehavior,字符串 resetOptionsString)+275 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,RunBehavior runBehavior,布尔 returnStream,布尔异步,Int32 超时,任务和任务,布尔异步写入,SqlDataReader ds)+1421 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite) +177 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) +208 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +163 System.Web.SessionState.SqlSessionStateStore.SqlExecuteNonQueryWithRetry(SqlCommand cmd, Boolean ignoreInsertPKException, String id) +98

[HttpException (0x80004005): 无法连接到 SQL Server 会话数据库。] System.Web.SessionState.SqlSessionStateStore.ThrowSqlConnectionException(SqlConnection conn,异常 e)+235 System.Web.SessionState.SqlSessionStateStore.SqlExecuteNonQueryWithRetry(SqlCommand cmd, Boolean ignoreInsertPKException, String id) +390 System.Web.SessionState.SqlSessionStateStore.SetAndReleaseItemExclusive(HttpContext context, String id, SessionStateStoreData item, Object lockId, Boolean newItem) +589 System.Web.SessionState.SessionStateModule.OnReleaseState(对象源,EventArgs eventArgs)+565 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

版本信息:Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.34009

http://i.stack.imgur.com/8BloW.png

【问题讨论】:

    标签: sql azure-sql-database azure-vpn


    【解决方案1】:

    SqlClient.SqlCommand 对象有一个属性 CommandTimeout。它的默认值为 30(秒)。您应该将其设置为更高的值。

    【讨论】:

      【解决方案2】:

      您可以将超时值设置得更高,也可以关闭超时值,就像我在下面的代码中所做的那样。请注意,如果保存数据的对象超过 2Gb,您可能会遇到错误。您可能需要考虑重新设计查询以一次获取较小的数据块。

      // I'm populating an ADO.Net DataTable for this demo but populate whatever object you'd like
      DataTable DtFromSQL = new DataTable();
      SqlConnection myConnection = new SqlConnection("ConnectionString");
      myConnection.Open();
      SqlDataReader myReader = null;
      SqlCommand myCommand = new SqlCommand("enter some SQL query here", myConnection);
      // A CommandTimeout Value of 0 turns the timout off, otherwise you can set it to some value in seconds
      myCommand.CommandTimeout = 0;  
      myReader = myCommand.ExecuteReader();
      DtFromSQL.Load(myReader8);
      myConnection.Close();
      DtFromSQL;
      

      【讨论】:

        猜你喜欢
        • 2013-04-28
        • 2019-03-13
        • 1970-01-01
        • 1970-01-01
        • 2017-01-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多