Connection was closed error between HttpClient and ASP.NET Core 2.0 webservice

前端 未结 1 630
囚心锁ツ
囚心锁ツ 2021-02-15 13:18

I have a ASP.NET Core 2.0 webservice running on IIS. One of controller\'s methods looks more or less like this:

[HttpGet()]
public IActionResult Test()
{
    //          


        
相关标签:
1条回答
  • 2021-02-15 14:03

    It looks like your throughput drops below the minimum data rate. This behavior is described in Kestrel Fundamentals:

    Kestrel checks every second if data is coming in at the specified rate in bytes/second. If the rate drops below the minimum, the connection is timed out. The grace period is the amount of time that Kestrel gives the client to increase its send rate up to the minimum; the rate is not checked during that time. The grace period helps avoid dropping connections that are initially sending data at a slow rate due to TCP slow-start.

    The default minimum rate is 240 bytes/second, with a 5 second grace period.

    A minimum rate also applies to the response. The code to set the request limit and the response limit is the same except for having RequestBody or Response in the property and interface names.

    You can configure this in Program.cs like this:

    var host = new WebHostBuilder() 
        .UseKestrel(options => 
        { 
            options.Limits.MinResponseDataRate = null;
        })
    

    Setting this option to null indicates no minimum data rate should be enforced.

    0 讨论(0)
提交回复
热议问题