Bug 15699 - [HttpClient] Exception in WebConnection.cs when packet loss is 50%
Summary: [HttpClient] Exception in WebConnection.cs when packet loss is 50%
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 7.0.3.x
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Martin Baulig
URL:
Depends on:
Blocks:
 
Reported: 2013-10-25 11:13 UTC by Stephen Shaw
Modified: 2016-11-11 09:33 UTC (History)
3 users (show)

Tags:
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:
Status:
RESOLVED FIXED

Description Stephen Shaw 2013-10-25 11:13:12 UTC
If in the developer options I duplicate the 100% loss profile and change it to 50 I seem to be able to get this crash consistently.

Here is the stack trace:

Object reference not set to an instance of an object


  at System.Net.WebConnection.Write (System.Net.HttpWebRequest request, System.Byte[] buffer, Int32 offset, Int32 size, System.String& err_msg) [0x000e0] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebConnection.cs:1168 
  at System.Net.WebConnectionStream.WriteHeaders () [0x00015] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebConnectionStream.cs:679 
  at System.Net.WebConnectionStream.SetHeaders (System.Byte[] buffer) [0x000f8] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebConnectionStream.cs:649 
  at System.Net.HttpWebRequest.SendRequestHeaders (Boolean propagate_error) [0x0010c] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:1257 


Here is my current call stack:

System.Net.WebConnection.Write (request=Value not available, buffer=Value not available, offset=Value not available, size=Value not available, err_msg=Value not available) in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebConnection.cs:1168
System.Net.WebConnectionStream.WriteHeaders () in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebConnectionStream.cs:679
System.Net.WebConnectionStream.SetHeaders (buffer=Value not available) in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebConnectionStream.cs:649
System.Net.HttpWebRequest.SendRequestHeaders (propagate_error=Value not available) in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:1257
System.Net.WebConnectionStream.WriteRequest () in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebConnectionStream.cs:710
System.Net.HttpWebRequest.CheckIfForceWrite () in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:877
System.Net.HttpWebRequest.BeginGetResponse (callback=Value not available, state=Value not available) in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:900
System.Threading.Tasks.TaskFactory<System.Net.WebResponse>.FromAsyncBeginEnd (beginMethod=Value not available, endMethod=Value not available, state=Value not available, creationOptions=Value not available) in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/TaskFactory_T.cs
System.Threading.Tasks.TaskFactory<System.Net.WebResponse>.FromAsync (beginMethod=Value not available, endMethod=Value not available, state=Value not available, creationOptions=Value not available) in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/TaskFactory_T.cs
System.Threading.Tasks.TaskFactory<System.Net.WebResponse>.FromAsync (beginMethod=Value not available, endMethod=Value not available, state=Value not available) in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/TaskFactory_T.cs
System.Net.WebRequest.GetResponseAsync () in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebRequest.cs:513
System.Net.Http.HttpClientHandler.SendAsync () in /Developer/MonoTouch/Source/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:319
System.Threading.Tasks.ActionContinuation.Execute () in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/TaskContinuation.cs:124
System.Threading.Tasks.Task.ProcessCompleteDelegates () in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/Task.cs:556
System.Threading.Tasks.Task.Finish () in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/Task.cs:539
System.Threading.Tasks.Task<System.IO.Stream>.TrySetResult (result=Value not available) in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/Task_T.cs
System.Threading.Tasks.TaskCompletionSource<System.IO.Stream>.TrySetResult (result=Value not available) in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/TaskCompletionSource.cs
System.Threading.Tasks.TaskCompletionSource<System.IO.Stream>.SetResult (result=Value not available) in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/TaskCompletionSource.cs
System.Threading.Tasks.TaskFactory<System.IO.Stream>.InnerInvoke (tcs=Value not available, endMethod=Value not available, l=Value not available) in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/TaskFactory_T.cs
System.Threading.Tasks.TaskFactory<System.IO.Stream>.FromAsyncBeginEnd.AnonymousMethod__6D (l=Value not available) in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/TaskFactory_T.cs
System.Net.WebAsyncResult.CB (unused=Value not available) in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebAsyncResult.cs:151




/Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebConnection.cs line: 1168

		internal bool Write (HttpWebRequest request, byte [] buffer, int offset, int size, ref string err_msg)
		{
			err_msg = null;
			Stream s = null;
			lock (this) {
				if (Data.request != request)
					throw new ObjectDisposedException (typeof (NetworkStream).FullName);
				if (nstream == null)
					return false;
				s = nstream;
			}

			try {
				s.Write (buffer, offset, size);
				// here SSL handshake should have been done
				if (ssl && !certsAvailable)
					GetCertificates ();
			} catch (Exception e) {
				err_msg = e.Message;
				WebExceptionStatus wes = WebExceptionStatus.SendFailure;
				string msg = "Write: " + err_msg;
				if (e is WebException) {
					HandleError (wes, e, msg);
					return false;
				}

				// if SSL is in use then check for TrustFailure
				if (ssl) {
#if SECURITY_DEP && MONOTOUCH
					HttpsClientStream https = (nstream as HttpsClientStream);
					if (https.TrustFailure) {     <-----------------------------------------------------(line 1168)
#else
					if ((bool) piTrustFailure.GetValue (nstream, null)) {
#endif
						wes = WebExceptionStatus.TrustFailure;
						msg = "Trust failure";
					}
				}

				HandleError (wes, e, msg);
				return false;
			}
			return true;
		}
Comment 1 Stephen Shaw 2013-10-25 11:16:07 UTC
I think this is the call that we are making:


		var response = await network.PostRequestAsync();


		public async Task<HttpResponseMessage> PostRequestAsync ()
		{
			return await _client.PostAsync (URL, SetupHttpContent ());
		}



		private HttpContent SetupHttpContent ()
		{
			HttpContent content = new StringContent (Body);
			content.Headers.ContentType = new MediaTypeHeaderValue ("application/json");

			return content;
		}
Comment 2 Rodrigo Kumpera 2013-10-25 11:20:50 UTC
Hey Martin,

Could you take a look at this one?

Thanks.
Comment 3 Stephen Shaw 2013-10-25 11:24:46 UTC
Let me know what else I can provide.
Comment 4 Martin Baulig 2016-11-11 09:33:26 UTC
Closing ancient bugs, please reopen if you're still having this problem.