title: Error occurred during the pre-login handshake
body: <p><strong>Please read in the entirety before marking this as duplicate.</strong></p>
  
  <p>In a project that I am debugging I receive a SqlException saying the following:</p>
  
  <blockquote>
    <p>Additional information: 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.)</p>
  </blockquote>
  
  <p>This occurred during a debugging session where the previous session executed only seconds before without problem.  Since the initial exception, I am unable to connect to the database server in this project.  <strong>The exception is thrown on the SqlConnection.Open() method call.</strong></p>
  
  <h1>The Background</h1>
  
  <p>This is not the first time that I have received this.  Previously I struggled with it for two weeks eventually initiating a Microsoft support ticket for it.  In that instance it turned out the ApplicationName property on the connection string was too long (we were using the fully qualified assembly name) and shortening it alleviated the problem.</p>
  
  <p>This time around, there is </p>
  
  <ul>
  <li>No ApplicationName value supplied</li>
  <li>WinSocks is in its default state</li>
  <li>Antivirus (ESET) was disabled and was not the issue.</li>
  <li>Nothing was installed between a working and non-working debug session</li>
  </ul>
  
  <p>Finally, on a whim, I created a new project whose sole purpose was to connect to this same SQL server.  I copied the connection string from the non-working project, into the new project and it connects.  Is there some kind of per-project connection caching going on?  Something that survives a Clean>Rebuild and a restart of Visual Studio and Windows too?</p>
  
  <h1>Relevant Code</h1>
  
  <pre><code>    public SqlConnection OpenSqlConnection(string connectionString)
      {
          var conn = new SqlConnection(connectionString);
          conn.Open();
          _connectionString = connectionString;
          var sb = new SqlConnectionStringBuilder(_connectionString);
          _server = sb.DataSource;
          _database = sb.InitialCatalog;
          return conn;
      }
  </code></pre>
  
  <p>The connection string that is being passed in is output from a SqlConnectionStringBuilder elsewhere in the application.  The connection string is similar to: <code>"Data Source=SERVER;Initial Catalog=DATABASE;Integrated Security=True;Connect Timeout=60"</code></p>