asp.net - SQL Server 登录前握手确认错误

标签 asp.net sql-server asp-classic sql-server-2012 iis-8

这个问题在这里已经有了答案:





Connection to SQL Server Works Sometimes

(23 个回答)


6年前关闭。




我们有一个混合了经典 ASP、内联 .Net 和已编译 .Net 的生产网站,它与 SQL Server 实例对话,其中两者都是同一物理机器上的 VM,并且那里的一切都运行良好。为了对新功能进行一些测试,我创建了该站点的 QA 版本,并将其设置为连接到托管在另一台物理服务器上的 VM 上的数据库。它们是不同的网络(DMZ/内部),但都在同一个千兆机架上,因此连接速度应该不是问题。

我们遇到的问题是 QA 版本会工作一段时间然后突然死掉,直到我重新启动应用程序池和站点。这不是负载问题,因为只有我和另外两个人在测试此过程,并且我已确认 QA 数据库所在的服务器没有资源问题(16GB RAM、3.2GB 正在使用和处理器利用率悬停在2% 范围)。页面的所有变体(经典 ASP、内联 .Net 和编译的 .Net 页面)都会出现特定错误(如下所示)。根据我所做的所有研究,我不断指出这是一个防火墙问题,但我们甚至打开了两台服务器之间的所有端口,它仍然会发生。最奇怪的部分是,当我们在 ASA (5515-X) 上启用跟踪时,它几乎看不到任何流量,有时站点会立即返回该错误,而其他时候则需要 30 多秒。有问题的页面也没有进行任何密集的查找(死亡的一页总共抓取了大约 60 条记录)。这是完整的错误/堆栈跟踪:

  [Win32Exception (0x80004005): The wait operation timed out]

  [SqlException (0x80131904): Connection Timeout Expired.  The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement.  This could be because the pre-login handshake failed or the server was unable to respond back in time.  The duration spent while attempting to connect to this server was - [Pre-Login] initialization=21008; handshake=12; ]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +6749670
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +815
   System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error) +817
   System.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync() +344
   System.Data.SqlClient.TdsParserStateObject.TryReadNetworkPacket() +48
   System.Data.SqlClient.TdsParser.ConsumePreLoginHandshake(Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean& marsCapable) +126
   System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) +693
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +219
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +6777754
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +6778255
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData) +878
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +1162
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +72
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +6781425
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +103
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +2105
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +116
   System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +1089
   System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +6785863
   System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +233
   System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +278
   System.Data.SqlClient.SqlConnection.Open() +239
   System.Web.UI.Control.LoadRecursive() +71
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178

我会展示一个代码块,但是由于所有页面一旦出现就开始死掉它不会有多大好处。这一切都在生产中运行良好,因此唯一的区别是虚拟机位于不同的物理主机上,但鉴于它都是新硬件,没有理由这应该有问题。

我在这里也遇到过很多事情,使用 exec sp_updatestatsdbcc freeproccache ,但是这些似乎都没有改变。

我完全迷路了,有什么建议吗?

最佳答案

SQL Express 2014 也有类似的问题,原来是 Windows 防火墙问题,我们的一些服务器上有 SQL 2005/2008,都禁用了 Windows 防火墙。

在我的电脑上进行了更改,之后效果很好!

谢谢

布伦丹

关于asp.net - SQL Server 登录前握手确认错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22566795/

相关文章:

c# - 将 Windows 窗体应用程序转换为 Asp.net

c# - 如何在 ASP.NET C# 中打印 div

asp-classic - ASP 在两个页面之间丢失 session

c# - 文本框输入控件(字符数、字符类型)

c# - 是否可以在 Asp.NET razor 代码中嵌套 foreach 循环?

sql - 根据另一列的值选择特定列

sql - MS SQL 临时表循环

python - 使用 SqlAlchemy 执行原始查询(在 SQL-Server 数据库和 Pymssql 上)时,传递的参数无法识别并引发 SQL 错误

asp.net - 如何在 ASP.NET 中使用经典 ASP Session 对象读取 session 变量

asp-classic - 如何避免在 MoveFirst 上重新执行查询