title: A transport-level error has occurred (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.)
body: <p>I have read both these SO questions and the MS Docs:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/41927096/unexplained-sql-errors-in-production-environment-possibly-network-related">Unexplained SQL errors in production environment - possibly network related</a></li>
  <li><a href="https://stackoverflow.com/questions/24207116/the-semaphore-timeout-period-has-expired-sql-azure">&quot;The semaphore timeout period has expired&quot; SQL Azure</a></li>
  <li><a href="https://docs.microsoft.com/en-us/azure/sql-database/sql-database-connectivity-issues#retry-logic-for-transient-errors" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/azure/sql-database/sql-database-connectivity-issues#retry-logic-for-transient-errors</a></li>
  </ul>
  
  <p>And have the same error. I did not have any of these in my ConnectionString:
  ConnectRetryCount, ConnectRetryInterval or Connection Timeout.</p>
  
  <p>This is a method of my DB class:</p>
  
  <pre><code>public DataTable ExecuteSqlCommand(SqlCommand com)
  {
      var retryStrategy = new Incremental(5, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2));
      var retryPolicy = new RetryPolicy&lt;SqlDatabaseTransientErrorDetectionStrategy&gt;(retryStrategy);
  
      SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DataContext"].ToString());
  
      com.Connection = con;
      SqlDataAdapter da = new SqlDataAdapter(com);
      DataTable dt = new DataTable();
      try
      {
          retryPolicy.ExecuteAction(() =&gt;
          {
              con.Open();
              da.Fill(dt);
          });
      }
      catch (Exception e)
      {
          var telemetry = new TelemetryClient(); // app insights (azure)
          telemetry.TrackException(e);
      }
      finally
      {
          con.Close();
      }
      return dt;
  }
  </code></pre>
  
  <p>So what would be better? Remove the retry stuff from my code and use the attributes in my connection string? Let the framework do the work? Or is my current retry code sufficient? I have the feeling that the enterprise lib and retry stuff is obsolete, but cannot find a good source to confirm my thoughts.</p>
  
  <p>I am using 4.7 and also have EF 6.2, but most queries are just <code>SqlCommands</code> using the code from above.</p>
  
  <p><a href="https://i.stack.imgur.com/azCKM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/azCKM.png" alt="enter image description here"></a></p>