asp.net – 间歇性SQL连接错误
|
我有一个ASP.NET(Sitecore)应用程序,日志在我们客户的生产环境中显示间歇性的SQL连接错误.例外情况如下: Exception: System.Data.SqlClient.SqlException Message: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider,error: 40 - Could not open a connection to SQL Server) Source: .Net SqlClient Data Provider at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity,SqlConnectionString connectionOptions,SqlCredential credential,Object providerInfo,String newPassword,SecureString newSecurePassword,Boolean redirectedUserInstance,SqlConnectionString userConnectionOptions,SessionData reconnectSessionData,DbConnectionPool pool,String accessToken,Boolean applyTransientFaultHandling) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options,DbConnectionPoolKey poolKey,Object poolGroupProviderInfo,DbConnection owningConnection,DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool,DbConnection owningObject,DbConnectionOptions options,DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject,DbConnectionOptions userOptions,DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject,DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,UInt32 waitForMultipleObjectsTimeout,Boolean allowCreate,Boolean onlyOneCheckConnection,DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,TaskCompletionSource`1 retry,DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,DbConnectionInternal oldConnection,DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection,DbConnectionFactory connectionFactory,DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) at System.Data.SqlClient.SqlConnection.Open() at Sitecore.Data.DataProviders.Sql.DataProviderCommand..ctor(IDbCommand command,DataProviderTransaction transaction,Boolean openConnection) at Sitecore.Data.DataProviders.Sql.SqlDataApi.<>c__DisplayClass4.<CreateCommand>b__3() at Sitecore.Data.DataProviders.NullRetryer.Execute[T](Func`1 action,Action recover) at Sitecore.Data.DataProviders.Sql.SqlDataApi.<>c__DisplayClass12.<CreateReader>b__10() at Sitecore.Data.DataProviders.NullRetryer.Execute[T](Func`1 action,Action recover) at Sitecore.Data.DataProviders.Sql.SqlDataApi.CreateReader(String sql,Object[] parameters) at Sitecore.Data.DataProviders.Sql.SqlDataApi.<CreateObjectReader>d__6`1.MoveNext() at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source) at Sitecore.Eventing.EventQueue.ProcessEvents(Action`2 handler) at Sitecore.Eventing.EventProvider.RaiseQueuedEvents() Nested Exception Exception: System.ComponentModel.Win32Exception Message: The network path was not found 6420 16:53:53 ERROR Exception processing remote events from database: web Exception: System.Data.SqlClient.SqlException Message: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider,error: 40 - Could not open a connection to SQL Server) Source: .Net SqlClient Data Provider at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,Object[] parameters) at Sitecore.Data.DataProviders.Sql.SqlDataApi.<CreateObjectReader>d__6`1.MoveNext() at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source) at Sitecore.Eventing.EventQueue.ProcessEvents(Action`2 handler) at Sitecore.Eventing.EventProvider.RaiseQueuedEvents() Nested Exception Exception: System.ComponentModel.Win32Exception Message: The network path was not found 如果您提供的连接字符串无效,而您指定的服务器不存在或无法在网络上访问,则此错误是典型的.但是,该网站99%的时间都能正常运行. 在此示例中,错误来自Sitecore的RaiseQueuedEvents计划任务,但异常也是从其他各个地方引发的,包括在网站中点击URL时产生的http 500. 有趣的是它们是波浪形的,即在几秒钟的时间内可能有多达100个例外. 管理服务器的客户基础架构团队非常坚定地认为它不是网络问题,并且应用程序代码有问题,并且报告在这些异常似乎发生时数据库流量有所增加:
解决方法它与Sitecore无关,但我之前看到过与另一个内容管理系统非常相似的情况.我也遇到了类似的挑战,基础设施工作人员确信数据库服务器很好,问题出在网站上.我怀疑网络问题,所以我的方法是: >我写了一个SQL脚本,可以从命令行运行,并显示相同的连接问题. 我的测试显示,当脚本在数据库服务器上运行时,根本无法重现该错误,但是当从Web服务器的命令行运行时确实发生了错误.这证明支持我的预感,即问题与连接有关,并且与网站或数据库服务器无关. 这将注意力集中在防火墙的设置上,将网站的DMZ与SQL服务器所在的内部网络分开.这个防火墙是一个负载平衡的对 – 我们最终能够找到一个微妙的配置差异,这导致第二个盒子终止通过第一个盒子启动的连接. 这个特定问题似乎不太可能导致问题 – 但您可能会发现提出测试的整体方法可以帮助解决问题的原因有用吗? (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net-mvc – 当在视图中使用ko时,ko.applyBindings给出错
- asp.net – 提高性能的最佳方法(并以某种方式包括故障转移)
- asp.net – 从URLReferrer获取querystring
- 将ASP.NET TextBox作为HTML5输入类型“Number”
- asp.net-mvc-3 – 任何好的样品开始使用Dapper?
- asp.net-mvc – 当OutputPath设置时,“没有为项目设置Outpu
- 剃刀 – 将MVC3应用程序迁移到MVC4:编译器错误消息:CS151
- .net – 设置可用于AppFabric缓存的内存量
- asp.net-mvc – ASP.NET MVC模型/ ViewModel验证
- asp.net-mvc – 未找到MVC 6 404
- asp.net – 为什么我不能使用NuGet删除包?
- asp.net – 如何在使用System.Web.Optimization时
- asp.net-mvc-3 – MVC3强制验证隐藏字段
- asp.net – OutOfMemoryException当发送大文件50
- 在ASP.NET RadioButtonList ListItem上设置CSS类
- ASP.NET c#获取屏幕宽度(以像素为单位)
- entity-framework – 在新配置下在EF7中切换Prox
- asp.net – 从类型’DBNull’到类型’String’的
- asp.net-web-api – webapi批处理和委托处理程序
- asp.net – IDENTITY_INSERT设置为关闭错误
