gpt4 book ai didi

c# - BadHttpRequestException : Reading the request body timed out due to data arriving too slowly. 请参阅 ASP.NET 核心 2.2 上的 MinRequestBodyDataRate

转载 作者:行者123 更新时间:2023-12-03 23:59:06 28 4
gpt4 key购买 nike

我正在使用用 ASP.NET core 2.2 开发的 aspnetboilerplate 解决方案。
后端部署在 azure 上,并使用提供的 SQL 服务器。
有时,当后端有很多请求要处理时,它会记录此异常:

ERROR 2020-11-20 12:28:21,968 [85 ] Mvc.ExceptionHandling.AbpExceptionFilter - Reading the request body timed out due to data arriving too slowly. See MinRequestBodyDataRate.Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Reading the request body timed out due to data arriving too slowly. See MinRequestBodyDataRate.


我试图解决这个问题,将此代码添加到我的 Program.cs
 namespace WorkFlowManager.Web.Host.Startup
{
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel(options =>
{
options.Limits.MinResponseDataRate = null;
});

BuildWebHost(args).Run();
}

public static IWebHost BuildWebHost(string[] args)
{
return WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
}
}
但问题并没有解决。

最佳答案

您共享的异常表明应用程序在“读取”请求时出现问题。

Reading the request body timed out due to data arriving too slowly. SeeMinRequestBodyDataRate.


但是您正在尝试设置 MinResponseDataRate .
请考虑更新 MinRequestBodyDataRate .
而不是将值设置为 null , 请检查 documentation并尝试为请求设置有意义的值。
默认值为:

The default minimum rate is 240 bytes/second with a 5 second graceperiod.


你可以这样改变:
.UseKestrel(options =>
{
options.Limits.MinRequestBodyDataRate =
new MinDataRate(bytesPerSecond: 100, gracePeriod: TimeSpan.FromSeconds(10));
});

关于c# - BadHttpRequestException : Reading the request body timed out due to data arriving too slowly. 请参阅 ASP.NET 核心 2.2 上的 MinRequestBodyDataRate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64933345/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com