Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Core 3.1 HttpMessageHandler cleanup cycle

I see these messages in my debug log:

[23:29:12 DBG] HttpMessageHandler expired after 120000ms for client 'default' {"EventId": {"Id": 103, "Name": "HandlerExpired"}, "SourceContext": "Microsoft.Extensions.Http.DefaultHttpClientFactory"}

[23:29:22 DBG] Starting HttpMessageHandler cleanup cycle with 1 items {"EventId": {"Id": 100, "Name": "CleanupCycleStart"}, "SourceContext": "Microsoft.Extensions.Http.DefaultHttpClientFactory"}

[23:29:22 DBG] Ending HttpMessageHandler cleanup cycle after 1.9126ms - processed: 0 items - remaining: 1 items {"EventId": {"Id": 101, "Name": "CleanupCycleEnd"}, "SourceContext": "Microsoft.Extensions.Http.DefaultHttpClientFactory"}

[23:29:32 DBG] Starting HttpMessageHandler cleanup cycle with 1 items {"EventId": {"Id": 100, "Name": "CleanupCycleStart"}, "SourceContext": "Microsoft.Extensions.Http.DefaultHttpClientFactory"}

[23:29:32 DBG] Ending HttpMessageHandler cleanup cycle after 0.1306ms - processed: 0 items - remaining: 1 items {"EventId": {"Id": 101, "Name": "CleanupCycleEnd"}, "SourceContext": "Microsoft.Extensions.Http.DefaultHttpClientFactory"}

These messages never end, but I do not use any of those in my application. I have some undisposed object, why do I always have one item?

This is my code in Startup.cs:

services.AddHttpClient("default", c =>
        {
            c.DefaultRequestHeaders.Add("Accept-Encoding", "gzip, deflate");
            c.Timeout = TimeSpan.FromMinutes(120);
        }).ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
        {
            Proxy = WebRequest.DefaultWebProxy,
            AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip
        });
like image 916
FedeC87p Avatar asked Jan 25 '23 20:01

FedeC87p


1 Answers

This github issue discussed a similar issue, and it seems default behavior.

And if you do not want to get the log of Microsoft.Extensions.Http.DefaultHttpClientFactory category, you can set it at log level "Information" and higher.

"Microsoft.Extensions.Http.DefaultHttpClientFactory": "Information"
like image 188
Fei Han Avatar answered Feb 04 '23 11:02

Fei Han