Таймауты в основной службе .net - PullRequest
0 голосов
/ 22 ноября 2018

У меня есть служба .NET Core, которую я размещаю в Azure в качестве службы приложений.По умолчанию это был тайм-аут через 2 минуты, но затем я добавил requestTimeout = "00:30:00" в элемент aspNetCore файла web.config.

Это, однако, увеличивает период ожидания только приблизительно до 4минут.

Я ищу, откуда исходит это значение и как его увеличить.

Ниже приведены метод BuildWebHost и методы запуска: Configure и ConfigureServices, которые я использую.

public static IWebHost BuildWebHost(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
        .ConfigureAppConfiguration((context, config) =>
        {
            IHostingEnvironment env = context.HostingEnvironment;
            config.SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true)
                .AddEnvironmentVariables();

            config.AddAzureKeyVault(
                Environment.GetEnvironmentVariable("Vault"),
                Environment.GetEnvironmentVariable("VaultClientId"),
                Environment.GetEnvironmentVariable("VaultClientSecret")
            );

            var builtConfig = config.Build();
        })
        .ConfigureServices(services =>
        {
            // my services here
        })
        .UseStartup<Startup>()
        .Build();
}

public void ConfigureServices(IServiceCollection services)
{
    services.AddCors();

    // my interfaces here

    services.AddAuthentication(sharedOptions =>
    {
        sharedOptions.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
    })
    .AddJwtBearer("Jwt", options =>
    {
        options.TokenValidationParameters = new TokenValidationParameters
        {
            ValidateIssuer = true,
            ValidateAudience = true,
            ValidateLifetime = true,
            ValidateIssuerSigningKey = true,
            ValidIssuer = Configuration["Jwt:Issuer"],
            ValidAudience = Configuration["Jwt:Issuer"],
            IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Environment.GetEnvironmentVariable("JWT_KEY")))
        };
    })
    .AddScheme<AuthenticationSchemeOptions, ApiKeyHandler>("ApiKey", null);

    services.AddLogging(builder =>
    {
        builder.AddConfiguration(Configuration.GetSection("Logging"))
        .AddConsole()
        .AddDebug();
    });

    services.AddResponseCaching();

    services.AddSwaggerGen(c =>
    {
        c.SwaggerDoc("v1", new Info { Title = "MyApp", Version = "v1" });
    });

    services.AddMvc();
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    app.UseCors(builder =>
    {
        builder.WithOrigins("*")
        .AllowAnyHeader()
        .AllowAnyMethod()
        .AllowCredentials();
    });

    app.UseDeveloperExceptionPage();
    app.UseSwagger();
    app.UseSwaggerUI(c =>
    {
        c.RoutePrefix = string.Empty;
        c.SwaggerEndpoint("/swagger/v1/swagger.json", "MyApp");
    });

    app.UseResponseCaching();
    app.UseAuthentication();
    app.UseMvc();
}

А вот мой web.config также для справки:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
      </handlers>
      <aspNetCore requestTimeout="00:30:00" processPath="dotnet" arguments=".\MyApp.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
    </system.webServer>
  </location>
</configuration>

Любая помощь будет оценена.

...