简体   繁体   中英

An error occurred during the pre-login handshake

After a few years of development my C#/.Net program is having this issue while attempting to connect to a MS Sql server database. I have no idea on how I can fix it. It's occuring only when attempting to write on a specific table. After clearing that table I noticed a decreased frenquency of this issue but it's still happening from time to time;

Here are the two exceptions I get :

  1. System.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 0 - The wait operation timed out.) ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) ... at System.Data.Linq.DataQuery 1.System.Linq.IQueryProvider.Execute[S](Expression >expression) at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable 1 source)

2.

System.Data.SqlClient.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=42511; handshake=6001; ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) ...

I encountered this same error in the past two days due to the installation of windows update KB2992611, which is a critical update to SChannel. I have not identified the reason that this breaks the pre-login handshake, but temporarily uninstalling this update restored the ability to connect to the SQL Server.

If the problem is intermittently, you should run a perfmon on the server and database monitor counters for the network card, specifically packet loss and overloads. I think that you should rule out connectivity issues, suddenly a switch may be the reason. If the problem out by configuring SQL Server or Firewall, the problem would recur.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM