I'm using aspnetboilerplate solution developed with ASP.NET core 2.2 . The backend is deployed on azure and it uses the SQL server provided.

Sometimes, when the backend has a lot of requests to handle, it logs this exception:

Mvc.ExceptionHandling.AbpExceptionFilter - An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure()' to the 'UseSqlServer' call. System.InvalidOperationException: An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure()' to the 'UseSqlServer' call. ---> System.Data.SqlClient.SqlException: A transport-level error has occurred when receiving results from the serv

I tried to solve this problem adding this code to my Startup.cs

public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            // MVC
            services.AddMvc(
                options => options.Filters.Add(new CorsAuthorizationFilterFactory(_defaultCorsPolicyName))
            ).AddJsonOptions(
            // To fix OldContract in Contract entity (self-referencing loop)

        services.AddDbContext<ManagerDbContext>(options =>
        {
            options.UseSqlServer(_appConfiguration["ConnectionStrings:Default"],
                sqlServerOptionsAction: builder =>
                {
                    builder.EnableRetryOnFailure(
                        maxRetryCount: 10,
                        maxRetryDelay: TimeSpan.FromSeconds(30),
                        errorNumbersToAdd: null);
                });
        });

    }

But the problem is not solved.

1

There are 1 best solutions below

0
On

you will have to add your error code in the list errorNumbersToAdd:

options.EnableRetryOnFailure(
        maxRetryCount: 3,
        maxRetryDelay: TimeSpan.FromSeconds(10),
        errorNumbersToAdd: new List<int> { Add your code here});