4

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) ...

sofsntp
  • 1,964
  • 23
  • 34
  • Have you ever search your exception messages on Google? I'm sure you can find a lot of results. – Soner Gönül Nov 11 '14 at 09:41
  • 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 Nov 11 '14 at 13:09
  • This is a a possible duplicate post. Please refer [http://stackoverflow.com/a/3270243/4243015][1] [1]: http://stackoverflow.com/a/3270243/4243015 – Rama Kathare Nov 14 '14 at 14:29
  • 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 Nov 17 '14 at 08:36
  • 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 Nov 19 '14 at 15:44
  • If you have already tried things to fix it, then please tell us what they are so that we do not repeat them here. – RBarryYoung Nov 20 '14 at 16:19
  • This error is usually a failure of the network security/connection encryption protocols/code. Unfortunately there are many, many possible causes, most having to do with either keys/certificates and exchange problems or else network configurations and hardware issues. FWIW, disabling encryption usually makes it go away. – RBarryYoung Nov 20 '14 at 16:24
  • Is that useful ? connectionString="Data Source=SERVER;Initial Catalog=CATALOG;Persist Security Info=True;User ID=USER;Password=PWD" ? – sofsntp Nov 20 '14 at 16:35
  • Is there something I can do to find out more precisely potential causes ? – sofsntp Nov 20 '14 at 16:37

2 Answers2

5

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.

jlddodger
  • 91
  • 1
  • Was it failing all the time with the update ? In my case it's failing about 0.5-1% of the time. – sofsntp Nov 17 '14 at 08:34
0

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.

Eduardo Vélez
  • 193
  • 1
  • 4