Bug 59779 - HttpClient, when using GZIP, hangs while sending multiple requests in parallel.
Summary: HttpClient, when using GZIP, hangs while sending multiple requests in parallel.
Status: ASSIGNED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Net.Http (show other bugs)
Version: master
Hardware: PC All
: --- normal
Target Milestone: Future Release
Assignee: Katelyn Gadd
URL:
Depends on:
Blocks:
 
Reported: 2017-09-27 08:22 UTC by Vladimir Kazakov
Modified: 2017-10-11 12:49 UTC (History)
4 users (show)

See Also:
Tags: bugpool
Is this bug a regression?: ---
Last known good build:


Attachments
The solution with a project that allows to reproduce the issue. (3.95 KB, application/x-zip-compressed)
2017-09-27 08:22 UTC, Vladimir Kazakov
Details

Description Vladimir Kazakov 2017-09-27 08:22:07 UTC
Created attachment 24951 [details]
The solution with a project that allows to reproduce the issue.

When using HttpClient that has a handler that enables GZIP (new HttpClient(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.GZip })), running multiple tasks in parallel that download some data (await HttpClient.GetAsync("https://jsonplaceholder.typicode.com/photos")) results in hanging until the HttpClient's timeout is reached. On my machine (64-bit Ubuntu 16.04 with all updates; Mono 5.2.0.224), I see that the maximum amount of tasks that can be successfully run in parallel is equal to 2. Any number above 2 results in hanging. This doesn't happen on Windows / .NET Framework. This also doesn't happen if GZIP is not used, which may mean that something is wrong with HttpClientHandler. I attached the solution with the code that reproduces the issue.
Comment 1 Katelyn Gadd 2017-10-11 06:36:56 UTC
The limit of two requests is due to https://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.defaultconnectionlimit(v=vs.110).aspx, so that's expected. Naturally the hang is not expected, but adjusting that value should allow you to get more parallel requests in general across both Mono and Windows .NET Framework if that matters for your use case.

I've verified that this occurs regardless of the use of HTTPS or HTTP, and it appears to happen against different web server software as well (including Amazon's CDN).

Note You need to log in before you can comment on or make changes to this bug.