4
votes

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.DataQuery1.System.Linq.IQueryProvider.Execute[S](Expression >expression) at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable1 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) ...

2
Have you ever search your exception messages on Google? I'm sure you can find a lot of results.Soner Gönül
yes I know Google. I found a lot of results but nothing helpful in my case. I am not asking often and I spent several hours looking for a fix.sofsntp
This is a a possible duplicate post. Please refer [stackoverflow.com/a/3270243/4243015][1] [1]: stackoverflow.com/a/3270243/4243015Rama Kathare
thanks but I have already seen this post. It is related to asp.net and a similar approach in my case did not fix the issue.sofsntp
Please post the connection string you are using to establish the connection. That may help people find out the cause of the issue.Only You

2 Answers

5
votes

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.

0
votes

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.