Bug 22724 - Mono HttpClientHandler does not support concurrent requests (Corrupts state)
Summary: Mono HttpClientHandler does not support concurrent requests (Corrupts state)
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 3.8.0
Hardware: All All
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL: https://bitbucket.org/tpurtell/mono-h...
Depends on:
Reported: 2014-09-07 14:32 UTC by T.J. Purtell
Modified: 2015-01-15 03:48 UTC (History)
9 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description T.J. Purtell 2014-09-07 14:32:52 UTC
If you run concurrent requests using the Mono HttpClientHandler, the network stack will JAM or throw numerous weird internal exceptions.  Mono 3.4 doesn't show this, but mono 3.6+ does show this.  Regular .NET does not have this issue either.

I originally discovered this on Android when I was trying to reduce GREF usage by switching from ModernHttpClient based off of OkHttp back to the mono Http stack.  I found that my application could not run successfully.  None the less, this applies across all mono platforms (ios/android/linux/etc)

I have created a test case that illustrates the issue.

You have to run the node js script inside so that the test case has a server to talk to.  When you run the test case, a working version of mono will complete (printing start/stop 10 times).  When you use a broken version of mono, it will hang completely, usually with no stops printed at all.

A working run should look like this
>lucite:mono-http-hang tj$ mono mono-http-hang/bin/Debug/mono-http-hang.exe
>stop 1
>stop 2
>stop 9
>stop 10
Comment 1 T.J. Purtell 2014-09-07 15:10:38 UTC
Comment 2 Marek Safar 2014-09-08 05:49:09 UTC
Fixed in master
Comment 3 William Grand 2014-09-22 14:58:44 UTC
Until this fix is released, does anyone know of a workaround for now?
Comment 5 Marek Safar 2014-09-25 03:28:57 UTC
It didn't make it to mono 3.10
Comment 6 Diego 2014-09-25 07:47:19 UTC
Does anyone know when this will be solved?
Comment 7 Jason Steele 2014-10-26 07:06:21 UTC
This is affecting me to in Xam.Android Any news on when the fix will be released?
Comment 8 Alexandre Pepin 2014-10-29 16:13:05 UTC
We are also having the same problem. Any update?
Comment 9 William Grand 2014-10-29 16:22:22 UTC
The workaround I found for now is to create a new HttpClient for each request and then dispose of it when you're done.
Comment 10 tmrog 2015-01-04 12:11:35 UTC
Is there an update on this?  I am running the latest stable Xamaron.Android and cannot make concurrent requests on Android and iOS seems fine.
Comment 11 Marek Safar 2015-01-05 11:48:55 UTC
You need Xamarin.Android 5.0 which is the first version with the fix
Comment 12 Marek Safar 2015-01-15 03:48:39 UTC
*** Bug 26044 has been marked as a duplicate of this bug. ***