A transport-level error has occurred (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.)

azure-sql-database c# enterprise-library entity-framework-6

Question

I've read the MS Docs as well as these SO questions:

and do the same mistake. ConnectRetryCount, ConnectRetryInterval, or Connection Timeout were not included in my ConnectionString.

Here's a function from my database class:

public DataTable ExecuteSqlCommand(SqlCommand com)
{
    var retryStrategy = new Incremental(5, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2));
    var retryPolicy = new RetryPolicy<SqlDatabaseTransientErrorDetectionStrategy>(retryStrategy);

    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DataContext"].ToString());

    com.Connection = con;
    SqlDataAdapter da = new SqlDataAdapter(com);
    DataTable dt = new DataTable();
    try
    {
        retryPolicy.ExecuteAction(() =>
        {
            con.Open();
            da.Fill(dt);
        });
    }
    catch (Exception e)
    {
        var telemetry = new TelemetryClient(); // app insights (azure)
        telemetry.TrackException(e);
    }
    finally
    {
        con.Close();
    }
    return dt;
}

What then would be preferable? Why not utilise the characteristics in my connection string instead of the retry things in my code? let the structure do the tasks Or does my existing retry code work well enough? The enterprise lib and retry material seems to be out of date, but I can't locate a reliable source to back up my suspicions.

I have 4.7 and EF 6.2, yet the majority of my queries are merelySqlCommands utilising the aforementioned coding.

enter image description here

1
1
12/5/2017 9:57:40 AM

Popular Answer

ZZZ_tmp
0
12/5/2017 4:04:17 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow