asp.Net   发布时间:2022-04-07  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了在ASP.NET应用程序中使用out-of-process会话状态的SQL Server的连接问题大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有几个ASP.NET应用程序部署在一个农场的4 Windows 2003机器。每个应用程序在IIS中使用单独的应用程序池和虚拟目录。它们严重依赖于在单个SQL Server 2000(< sessionstate mode =“sqlserver”... />)上持久化的会话。应用程序是针对.NET 3.0编译的,但是.NET 3.5 SP1安装在服务器上。

每个Web服务器接收大约10个请求/秒。每隔一段时间我在日志中得到一些例外:

System.Data.SqlClient.SqlException: A transport-level error has occurred when receiving results from the server. (provider: TCP Provider,error: 0 - The semaphore timeout period has expired.)
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception,Boolean breakConnection)
   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.ReadBuffer()
   at System.Data.SqlClient.TdsParserStateObject.ReadByte()
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,RunBehavior runBehavior,String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,Boolean returnStream,Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,String method,DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result,String methodName,Boolean sendToPipe)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at System.Web.SessionState.SqlSessionStateStore.SetAndReleaseItemExclusive(HttpContext context,String id,SessionStateStoreData item,Object lockId,Boolean newItem)

或其他:

System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. (provider: TCP Provider,error: 0 - An existing connection was forcibly closed by the remote host.)
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception,Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParserStateObject.WriteSni()
   at System.Data.SqlClient.TdsParserStateObject.WritePacket(Byte flushMode)
   at System.Data.SqlClient.TdsParserStateObject.ExecuteFlush()
   at System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray,Int32 timeout,Boolean inSchema,SqlNotificationRequest notificationRequest,TdsParserStateObject stateObj,Boolean isCommandProc)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,Boolean newItem)

或另一个:

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,TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior,String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader()
   at System.Web.SessionState.SqlSessionStateStore.DoGet(HttpContext context,Boolean getExclusive,Boolean& locked,TimeSpan& lockAge,Object& lockId,SessionStateActions& actionFlags)

这些错误每天发生几次,持续约1-2分钟,然后消失。有没有人遇到这样的问题?你可以建议我做什么,以进一步跟踪问题?对我来说,它看起来更像是网络问题,而不是应用程序。是否可以在SQL Server上的一些设置,无法处理这么多并发连接?任何建议将不胜感激。

更新:

我已经解决了这个问题,通过执行主要更新应用程序,以减少会话中存储的对象的数量和大小。

解决方法

传输级错误通常链接到连接到sql服务器被破坏…通常网络。

超时超时通常在sql查询运行时间过长时抛出。

所以我会排除故障的链接到您的Sql Server,然后监视,以查看什么查询是超时。

听起来像一个SQL作业正在运行,备份?这可能是锁定表或重新启动服务。

大佬总结

以上是大佬教程为你收集整理的在ASP.NET应用程序中使用out-of-process会话状态的SQL Server的连接问题全部内容,希望文章能够帮你解决在ASP.NET应用程序中使用out-of-process会话状态的SQL Server的连接问题所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: