Bug 7308 - Issue with concurrent HtppWebRequests
Summary: Issue with concurrent HtppWebRequests
Status: RESOLVED DUPLICATE of bug 7200
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.2.x
Hardware: PC Windows
: High critical
Target Milestone: ---
Assignee: Martin Baulig
Depends on:
Reported: 2012-09-19 15:04 UTC by Jared Reed
Modified: 2012-09-26 20:44 UTC (History)
4 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 Developer Community or GitHub 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 Jared Reed 2012-09-19 15:04:26 UTC
I am doing multiple HttpWebRequests for user's facebook profile images. I am finding that some images don't show up, and many images are linked to the wrong user in my list.

Upon diving deeper into the problem, I have found that if I make many HttpWebRequests at one time, many of those requests return with the wrong results (Results for on of my other request). It is almost like the request results get jumbled up and returned to the wrong AsyncCallbacks.

For example:
I request 1: Result timeout.
I request 2: Returns results for 3.
I request 3: Returns results for 1.

Here is a code snippet of what I am talking about. If you drop it in an Activity and call DoRequests() in the OnCreate method, you will see what I am talking about.

		private List<MyWebRequest> _requests = new List<MyWebRequest>();
		public void DoRequests()
			for (int i = 1; i <= 20; ++i)
				_requests.Add(new MyWebRequest() { Url = String.Format("http://physibricks.com/tests/{0}.txt", i), ExpectedResult = i.ToString() });
			for (int i = 0; i < _requests.Count; ++i)

		public class MyWebRequest
			public HttpWebRequest Request;
			public string Url;
			public string ExpectedResult;
			public string ActualResult;
			public bool ResultsMatch()
				return ExpectedResult == ActualResult;
			public void MakeRequest()
				Request = (HttpWebRequest)WebRequest.Create(Url);
				Request.BeginGetResponse(AsyncCallback, null);
			public void AsyncCallback(IAsyncResult asyncResult)
				HttpWebResponse response = (HttpWebResponse)Request.EndGetResponse(asyncResult);
				System.IO.Stream streamResponse = response.GetResponseStream();
				System.IO.StreamReader reader = new StreamReader(streamResponse);
				ActualResult = reader.ReadToEnd();

				if (ActualResult != ExpectedResult)
					Console.WriteLine("{0} - ({1} == {2}) {3}", (ActualResult == ExpectedResult), ActualResult, ExpectedResult, Url);
Comment 1 Martin Baulig 2012-09-26 20:44:14 UTC
This should now be fixed; mono/master commit 9a8ed89, mono/mono-2-10 commit 0fa7cd1

*** This bug has been marked as a duplicate of bug 7200 ***