Bug 41100 - When Posting using Xamarin.Android.Net.AndroidClientHandler, receiving "Unexpected end of stream error"
Summary: When Posting using Xamarin.Android.Net.AndroidClientHandler, receiving "Unexp...
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler (show other bugs)
Version: 6.0.0
Hardware: Macintosh Mac OS
: --- major
Target Milestone: 6.1.x (C7SR1)
Assignee: Marek Habersack
URL:
Depends on:
Blocks:
 
Reported: 2016-05-16 11:48 UTC by Alex Blount
Modified: 2016-07-22 17:39 UTC (History)
10 users (show)

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


Attachments
Output (66.57 KB, text/plain)
2016-05-17 08:51 UTC, Alex Blount
Details

Description Alex Blount 2016-05-16 11:48:59 UTC
When doing a basic post using HttpClient with the new Xamarin.Android.Net.AndroidClientHandler it fails with the following error:

Java.Net.Protocol Exception: Unexpected end of stream error

I have attached a sample project as reference.

************************************************************************************************************************
************************************************************************************************************************
=== Xamarin Studio Enterprise ===

Version 6.0 (build 5104)
Installation UUID: 0a507e03-edf9-4c18-aa43-678d57ed4f07
Runtime:
	Mono 4.4.0 (mono-4.4.0-branch/81f38a9) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 404000142

=== Xamarin.Profiler ===

Version: 0.32.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 7.3.1 (10188.1)
Build 7D1014

=== Xamarin.iOS ===

Version: 9.8.0.294 (Xamarin Enterprise)
Hash: 6950f7b
Branch: cycle7
Build date: 2016-04-24 15:35:14-0400

=== Xamarin.Android ===

Version: 6.1.0.48 (Xamarin Enterprise)
Android SDK: /Users/alexb/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.1
SDK Build Tools Version: 23.0.1

Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Android Player ===

Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.8.0.294 (Xamarin Enterprise)

=== Xamarin Inspector ===

Version: 0.8.0.0
Hash: dc081aa
Branch: master
Build date: Tue Apr 26 23:07:44 UTC 2016

=== Build Information ===

Release ID: 600005104
Git revision: 1345d355d4f1b9677d91e1290a6034e2047bdf36
Build date: 2016-04-26 12:21:45-04
Xamarin addins: 7d85147c75b6dbb4b351906636ef76fdf60307c2
Build lane: monodevelop-lion-cycle7

=== Operating System ===

Mac OS X 10.11.4
Darwin alexs-macbook.local 15.4.0 Darwin Kernel Version 15.4.0
    Fri Feb 26 22:08:05 PST 2016
    root:xnu-3248.40.184~3/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

Xamarin Inspector 0.8.0.0

************************************************************************************************************************
************************************************************************************************************************
Comment 2 Marek Habersack 2016-05-16 16:58:55 UTC
Alex, can you attach/paste the stack trace you get?
Comment 3 Alex Blount 2016-05-17 08:49:06 UTC
System.Diagnostics.Debugger.Mono_UnhandledException_internal() in 
System.Diagnostics.Debugger.Mono_UnhandledException(Java.Net.ProtocolException ex) in /Users/builder/data/lanes/2923/39a97ef2/source/mono/mcs/class/corlib/System.Diagnostics/Debugger.cs:122
object.467d0328-6f85-4705-9499-d0f088586d60( arg0,  arg1) in 
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in /Users/builder/data/lanes/2923/39a97ef2/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
System.Runtime.CompilerServices.AsyncMethodBuilderCore.AnonymousMethod__0(System.Runtime.ExceptionServices.ExceptionDispatchInfo state) in /Users/builder/data/lanes/2923/39a97ef2/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018
Android.App.SyncContext.Post.AnonymousMethod__0() in /Users/builder/data/lanes/2923/7334f6a9/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:18
Java.Lang.Thread.RunnableImplementor.Run() in /Users/builder/data/lanes/2923/7334f6a9/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:36
Java.Lang.IRunnableInvoker.n_Run(System.IntPtr jnienv, System.IntPtr native__this) in /Users/builder/data/lanes/2923/7334f6a9/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Java.Lang.IRunnable.cs:81
object.467d0328-6f85-4705-9499-d0f088586d60( arg0,  arg1) in 

***************************************************************************************
***************************************************************************************
Comment 4 Alex Blount 2016-05-17 08:51:20 UTC
Created attachment 16017 [details]
Output
Comment 6 Jacob 2016-06-01 20:20:39 UTC
Contacted Xamarin Support and they seem to push this issue forward now.

As a workaround i used ModernHttpClient instead, which seemed to solve the issue in my case.

Only change i basically did was adding the ModernHttpClient Nuget to all my projects, and then instead of using 'new HttpClient', i just used 'new HttpClient(new NativeMessageHandler())' instead.

Hope this can help someone :)
Comment 7 Robert 2016-06-02 21:24:08 UTC
+ 1 getting this too
Comment 8 Maxence MOHR @ KeeeX 2016-06-07 09:48:45 UTC
Hi ! 
Same problem here with Xamarin.Forms on Android. It works well with Xamarin.Forms on iOS.

** CODE *************************************************************************
private static async Task<HttpResponseMessage> post(string url, string content) {
	var client = new HttpClient ();
	client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("*/*"));
	client.DefaultRequestHeaders.TryAddWithoutValidation ("X-Keeex-Version", Consts.KEEEX_HDR_VERSION);
	client.DefaultRequestHeaders.TryAddWithoutValidation ("Host", Consts.KEEEX_API_HOST);
	client.DefaultRequestHeaders.TryAddWithoutValidation ("User-Agent", "Xamarin");

	StringContent strContent = new StringContent (content);
	strContent.Headers.Remove ("Content-Type");
	strContent.Headers.TryAddWithoutValidation ("Content-Type", "application/json");
	strContent.Headers.TryAddWithoutValidation ("Content-Length", "" + content.Length);

	return  await client.PostAsync (new Uri(url), strContent);
// EXCEPTION ON THE LINE BEFORE
}

** STACKTRACE *******************************************************************
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] Java.Net.ProtocolException: unexpected end of stream
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x43064b80 + 0x0002b> in <filename unknown>:0 
[MonoDroid]   at Java.Interop.JniEnvironment+InstanceMethods.CallIntMethod (JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) <0x42d71cf0 + 0x000cb> in <filename unknown>:0 
[MonoDroid]   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualInt32Method (System.String encodedMember, IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) <0x42d71af0 + 0x00093> in <filename unknown>:0 
[MonoDroid]   at Java.Net.HttpURLConnection.get_ResponseCode () <0x43063ec0 + 0x00043> in <filename unknown>:0 
[MonoDroid]   at Xamarin.Android.Net.AndroidClientHandler.DoProcessRequest (System.Net.Http.HttpRequestMessage request, Java.Net.HttpURLConnection httpConnection, CancellationToken cancellationToken) <0x43062670 + 0x0025f> in <filename unknown>:0 
[MonoDroid]   at Xamarin.Android.Net.AndroidClientHandler+<ProcessRequest>c__async1+<ProcessRequest>c__AnonStorey2.<>m__0 () <0x43062050 + 0x00037> in <filename unknown>:0 
[MonoDroid]   at System.Threading.Tasks.Task`1[TResult].InnerInvoke () <0x42d637a0 + 0x0005c> in <filename unknown>:0 
[MonoDroid]   at System.Threading.Tasks.Task.Execute () <0x42d63630 + 0x0005b> in <filename unknown>:0 
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x43064b80 + 0x0002b> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x43065cf0 + 0x000cf> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x43065b50 + 0x00097> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x42d82440 + 0x0003b> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () <0x42d823c0 + 0x00017> in <filename unknown>:0 
[MonoDroid]   at Xamarin.Android.Net.AndroidClientHandler+<ProcessRequest>c__async1.MoveNext () <0x43061000 + 0x004cb> in <filename unknown>:0 
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x43064b80 + 0x0002b> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x43065cf0 + 0x000cf> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x43065b50 + 0x00097> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x42d82440 + 0x0003b> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () <0x42d368d0 + 0x00017> in <filename unknown>:0 
[MonoDroid]   at Xamarin.Android.Net.AndroidClientHandler+<SendAsync>c__async0.MoveNext () <0x4304b6b0 + 0x0039b> in <filename unknown>:0 
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x43064b80 + 0x0002b> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x43065cf0 + 0x000cf> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x43065b50 + 0x00097> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x42d82440 + 0x0003b> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () <0x42d823c0 + 0x00017> in <filename unknown>:0 
[MonoDroid]   at System.Net.Http.HttpClient+<SendAsyncWorker>c__async0.MoveNext () <0x430588d0 + 0x004ab> in <filename unknown>:0 
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x43064b80 + 0x0002b> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x43065cf0 + 0x000cf> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x43065b50 + 0x00097> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x42d82440 + 0x0003b> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () <0x42d368d0 + 0x00017> in <filename unknown>:0 
[MonoDroid]   at KeeeX.API+<post>c__async1.MoveNext () <0x430494c0 + 0x003f3> in <filename unknown>:0 
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x43064b80 + 0x0002b> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x43065cf0 + 0x000cf> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x43065b50 + 0x00097> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x42d82440 + 0x0003b> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () <0x42d368d0 + 0x00017> in <filename unknown>:0 
[MonoDroid]   at KeeeX.API+<auth>c__async6.MoveNext () <0x42fe3590 + 0x0019b> in <filename unknown>:0 
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x43064b80 + 0x0002b> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x43065cf0 + 0x000cf> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x43065b50 + 0x00097> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x42d82440 + 0x0003b> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () <0x42d368d0 + 0x00017> in <filename unknown>:0 
[MonoDroid]   at KeeeX.API+<logIn>c__async5.MoveNext () <0x42fd8460 + 0x003e3> in <filename unknown>:0 
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x43064b80 + 0x0002b> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x43065cf0 + 0x000cf> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x43065b50 + 0x00097> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x42d82440 + 0x0003b> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () <0x42d368d0 + 0x00017> in <filename unknown>:0 
[MonoDroid]   at KeeeX.App+<login>c__async1.MoveNext () <0x42fd7a10 + 0x00157> in <filename unknown>:0 
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x43064b80 + 0x0002b> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x43065cf0 + 0x000cf> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x43065b50 + 0x00097> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x42d82440 + 0x0003b> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () <0x42d368d0 + 0x00017> in <filename unknown>:0 
[MonoDroid]   at KeeeX.App+<OnLoginClicked>c__async0.MoveNext () <0x42fd68c0 + 0x0037b> in <filename unknown>:0 
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x43064b80 + 0x0002b> in <filename unknown>:0 
[MonoDroid]   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (System.Object state) <0x43067870 + 0x0003f> in <filename unknown>:0 
[MonoDroid]   at Android.App.SyncContext+<Post>c__AnonStorey0.<>m__0 () <0x42d36820 + 0x0001d> in <filename unknown>:0 
[MonoDroid]   at Java.Lang.Thread+RunnableImplementor.Run () <0x42d31300 + 0x00039> in <filename unknown>:0 
[MonoDroid]   at Java.Lang.IRunnableInvoker.n_Run (IntPtr jnienv, IntPtr native__this) <0x42d31270 + 0x0003e> in <filename unknown>:0 
[MonoDroid]   at (wrapper dynamic-method) System.Object:8ec04ac8-d6bd-4d10-9a10-eca2e79990dc (intptr,intptr)
[MonoDroid]   --- End of managed exception stack trace ---
[MonoDroid] java.net.ProtocolException: unexpected end of stream
[MonoDroid] 	at com.android.okhttp.internal.http.HttpConnection$FixedLengthSink.close(HttpConnection.java:314)
[MonoDroid] 	at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:781)
[MonoDroid] 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:439)
[MonoDroid] 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:384)
[MonoDroid] 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:497)
[MonoDroid] 	at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
[MonoDroid] 	at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java)
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_throw'.
[Mono] Probing 'java_interop_jnienv_throw'.
[Mono] Found as 'java_interop_jnienv_throw'.
[AndroidRuntime] Shutting down VM
[AndroidRuntime] FATAL EXCEPTION: main
[AndroidRuntime] Process: com.keeex.keeex, PID: 2952
[AndroidRuntime] java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
[AndroidRuntime] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
[AndroidRuntime] Caused by: java.lang.reflect.InvocationTargetException
[AndroidRuntime] 	at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime] 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
[AndroidRuntime] 	... 1 more
[AndroidRuntime] Caused by: java.net.ProtocolException: unexpected end of stream
[AndroidRuntime] 	at com.android.okhttp.internal.http.HttpConnection$FixedLengthSink.close(HttpConnection.java:314)
[AndroidRuntime] 	at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:781)
[AndroidRuntime] 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:439)
[AndroidRuntime] 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:384)
[AndroidRuntime] 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:497)
[AndroidRuntime] 	at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
[AndroidRuntime] 	at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java)

** XAMARIN ABOUT ****************************************************************
Xamarin Studio Community
Version 6.1 (build 817)
Installation UUID: e5875e34-4b63-4bec-a0e6-b3bef8b2649d
Runtime:
	Mono 4.4.0 (mono-4.4.0-branch/fcf7a6d) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 404000148

NuGet
Version: 3.3.0.0

Xamarin.Profiler
Not Installed

Xamarin.Android
Version: 6.1.99.224 (Xamarin Studio Community)
Android SDK: /Users/fladnag/Library/Android/sdk
	Supported Android versions:
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		5.0    (API level 21)
		6.0    (API level 23)
		6.0.99 (API level 24)

SDK Tools Version: 25.1.7
SDK Platform Tools Version: 23.1.0
SDK Build Tools Version: 23.0.3
Java SDK: /usr
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Xamarin Android Player
Not Installed

Apple Developer Tools
Xcode 7.3.1 (10188.1)
Build 7D1014

Xamarin.iOS
Version: 9.9.0.719 (Xamarin Studio Community)
Hash: 3afb4af
Branch: master
Build date: 2016-04-24 15:13:41-0400

Xamarin.Mac
Version: 2.9.0.719 (Xamarin Studio Community)

Build Information
Release ID: 601000817
Git revision: 2335763551f9db8296b08542035977b899b7f3b7
Build date: 2016-04-25 10:45:36-04
Xamarin addins: 7f8c9ab2a981143a87fbd5adbde3f5890a838fde
Build lane: monodevelop-lion-cycle8-preview

Operating System
Mac OS X 10.11.5
Darwin MacBook-Air-de-Maxence.local 15.5.0 Darwin Kernel Version 15.5.0
    Tue Apr 19 18:36:36 PDT 2016
    root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64
Comment 9 trinnguyen 2016-06-16 06:54:10 UTC
+1 same problem. 

Enable Xamarin.Android.Net.AndroidClientHandler and got the same exception when request HttpClient.PostAsync()
Comment 10 Alberto Buratti 2016-06-16 12:36:23 UTC
I confirm the same problem on Windows 10 Enterprise with Visual Studio 2015. Call stack and Xamarin infos here:

** CODE *********************************************************************

HttpClient client = new HttpClient(new Xamarin.Android.Net.AndroidClientHandler());
StringContent content = new StringContent("{'key1':'value1', 'key2':'value2'}", Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync("http://myurl/", content);


** CALL STACK ***************************************************************

Unhandled Exception:

Java.Net.ProtocolException: unexpected end of stream

06-16 14:20:53.800 D/Mono    ( 4556): DllImport attempting to load: '/system/lib/liblog.so'.
06-16 14:20:53.800 D/Mono    ( 4556): DllImport loaded library '/system/lib/liblog.so'.
06-16 14:20:53.800 D/Mono    ( 4556): DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so').
06-16 14:20:53.800 D/Mono    ( 4556): Searching for '__android_log_print'.
06-16 14:20:53.800 D/Mono    ( 4556): Probing '__android_log_print'.
06-16 14:20:53.800 D/Mono    ( 4556): Found as '__android_log_print'.
06-16 14:20:53.800 I/MonoDroid( 4556): UNHANDLED EXCEPTION:
06-16 14:20:53.801 I/MonoDroid( 4556): Java.Net.ProtocolException: unexpected end of stream
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
06-16 14:20:53.801 I/MonoDroid( 4556):   at Java.Interop.JniEnvironment+InstanceMethods.CallIntMethod (JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00085] in /Users/builder/data/lanes/3204/804c6cb7/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:11484 
06-16 14:20:53.801 I/MonoDroid( 4556):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualInt32Method (System.String encodedMember, IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00031] in /Users/builder/data/lanes/3204/804c6cb7/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:206 
06-16 14:20:53.801 I/MonoDroid( 4556):   at Java.Net.HttpURLConnection.get_ResponseCode () [0x00000] in /Users/builder/data/lanes/3204/804c6cb7/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Java.Net.HttpURLConnection.cs:505 
06-16 14:20:53.801 I/MonoDroid( 4556):   at Xamarin.Android.Net.AndroidClientHandler.DoProcessRequest (System.Net.Http.HttpRequestMessage request, Java.Net.HttpURLConnection httpConnection, CancellationToken cancellationToken) [0x000a0] in /Users/builder/data/lanes/3204/804c6cb7/source/monodroid/src/Mono.Android/src/Xamarin.Android.Net/AndroidClientHandler.cs:228 
06-16 14:20:53.801 I/MonoDroid( 4556):   at Xamarin.Android.Net.AndroidClientHandler+<ProcessRequest>c__async1+<ProcessRequest>c__AnonStorey2.<>m__0 () [0x00000] in /Users/builder/data/lanes/3204/804c6cb7/source/monodroid/src/Mono.Android/src/Xamarin.Android.Net/AndroidClientHandler.cs:207 
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x00012] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/threading/Tasks/Future.cs:680 
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Threading.Tasks.Task.Execute () [0x00016] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502 
06-16 14:20:53.801 I/MonoDroid( 4556): --- End of stack trace from previous location where exception was thrown ---
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535 
06-16 14:20:53.801 I/MonoDroid( 4556):   at Xamarin.Android.Net.AndroidClientHandler+<ProcessRequest>c__async1.MoveNext () [0x000b3] in /Users/builder/data/lanes/3204/804c6cb7/source/monodroid/src/Mono.Android/src/Xamarin.Android.Net/AndroidClientHandler.cs:207 
06-16 14:20:53.801 I/MonoDroid( 4556): --- End of stack trace from previous location where exception was thrown ---
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357 
06-16 14:20:53.801 I/MonoDroid( 4556):   at Xamarin.Android.Net.AndroidClientHandler+<SendAsync>c__async0.MoveNext () [0x000c4] in /Users/builder/data/lanes/3204/804c6cb7/source/monodroid/src/Mono.Android/src/Xamarin.Android.Net/AndroidClientHandler.cs:195 
06-16 14:20:53.801 I/MonoDroid( 4556): --- End of stack trace from previous location where exception was thrown ---
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535 
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Net.Http.HttpClient+<SendAsyncWorker>c__async0.MoveNext () [0x000a9] in /Users/builder/data/lanes/1196/3e934261/source/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:276 
06-16 14:20:53.801 I/MonoDroid( 4556): --- End of stack trace from previous location where exception was thrown ---
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357 
06-16 14:20:53.801 I/MonoDroid( 4556):   at HttpTest.MainActivity+<Button_Click>d__2.MoveNext () [0x00060] in C:\Users\alberto\Documents\Visual Studio 2015\Projects\OauthTest\HttpTest\MainActivity.cs:38 
06-16 14:20:53.801 I/MonoDroid( 4556): --- End of stack trace from previous location where exception was thrown ---
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
06-16 14:20:53.801 I/MonoDroid( 4556):   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (System.Object state) [0x00000] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018 
06-16 14:20:53.801 I/MonoDroid( 4556):   at Android.App.SyncContext+<Post>c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/3204/804c6cb7/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:18 
06-16 14:20:53.801 I/MonoDroid( 4556):   at Java.Lang.Thread+RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/3204/804c6cb7/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:36 
06-16 14:20:53.801 I/MonoDroid( 4556):   at Java.Lang.IRunnableInvoker.n_Run (IntPtr jnienv, IntPtr native__this) [0x00009] in /Users/builder/data/lanes/3204/804c6cb7/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Java.Lang.IRunnable.cs:81 
06-16 14:20:53.801 I/MonoDroid( 4556):   at (wrapper dynamic-method) System.Object:4c36e62a-e9c7-459b-8548-231e3e233c52 (intptr,intptr)
06-16 14:20:53.801 I/MonoDroid( 4556):   --- End of managed exception stack trace ---
06-16 14:20:53.801 I/MonoDroid( 4556): java.net.ProtocolException: unexpected end of stream
06-16 14:20:53.801 I/MonoDroid( 4556): 	at com.android.okhttp.internal.http.HttpConnection$FixedLengthSink.close(HttpConnection.java:303)
06-16 14:20:53.801 I/MonoDroid( 4556): 	at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:619)
06-16 14:20:53.801 I/MonoDroid( 4556): 	at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:388)
06-16 14:20:53.801 I/MonoDroid( 4556): 	at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:332)
06-16 14:20:53.801 I/MonoDroid( 4556): 	at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:500)
06-16 14:20:53.801 I/MonoDroid( 4556): 	at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
06-16 14:20:53.801 I/MonoDroid( 4556): 	at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
06-16 14:20:53.802 D/Mono    ( 4556): DllImport searching in: '__Internal' ('(null)').
06-16 14:20:53.802 D/Mono    ( 4556): Searching for 'java_interop_jnienv_throw'.
06-16 14:20:53.802 D/Mono    ( 4556): Probing 'java_interop_jnienv_throw'.
06-16 14:20:53.802 D/Mono    ( 4556): Found as 'java_interop_jnienv_throw'.
An unhandled exception occured.

referenceTable GDEF length=670 1
referenceTable GSUB length=7202 1
referenceTable GPOS length=24560 1
referenceTable GDEF length=670 1
referenceTable GSUB length=7186 1
referenceTable GPOS length=26482 1
referenceTable head length=54 1
06-16 14:20:56.190 E/mono    ( 4556): 
06-16 14:20:56.190 E/mono    ( 4556): Unhandled Exception:
06-16 14:20:56.190 E/mono    ( 4556): Java.Net.ProtocolException: unexpected end of stream
06-16 14:20:56.190 E/mono    ( 4556):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
06-16 14:20:56.190 E/mono    ( 4556):   at Java.Interop.JniEnvironment+InstanceMethods.CallIntMethod (JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00085] in /Users/builder/data/lanes/3204/804c6cb7/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:11484 
06-16 14:20:56.190 E/mono    ( 4556):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualInt32Method (System.String encodedMember, IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00031] in /Users/builder/data/lanes/3204/804c6cb7/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:206 
06-16 14:20:56.190 E/mono    ( 4556):   at Java.Net.HttpURLConnection.get_ResponseCode () [0x00000] in /Users/builder/data/lanes/3204/804c6cb7/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Java.Net.HttpURLConnection.cs:505 
06-16 14:20:56.190 E/mono    ( 4556):   at Xamarin.Android.Net.AndroidClientHandler.DoProcessRequest (System.Net.Http.HttpRequestMessage request, Java.Net.HttpURLConnection httpConnection, CancellationToken cancellationToken) [0x000a0] in /Users/builder/data/lanes/3204/804c6cb7/source/monodroid/src/Mono.Android/src/Xamarin.Android.Net/AndroidClientHandler.cs:228 
06-16 14:20:56.190 E/mono    ( 4556):   at Xamarin.Android.Net.AndroidClientHandler+<ProcessRequest>c__async1+<ProcessRequest>c__AnonStorey2.<>m__0 () [0x00000] in /Users/builder/data/lanes/3204/804c6cb7/source/monodroid/src/Mono.Android/src/Xamarin.Android.Net/AndroidClientHandler.cs:207 
06-16 14:20:56.190 E/mono    ( 4556):   at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x00012] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/threading/Tasks/Future.cs:680 
06-16 14:20:56.190 E/mono    ( 4556):   at System.Threading.Tasks.Task.Execute () [0x00016] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502 
06-16 14:20:56.190 E/mono    ( 4556): --- End of stack trace from previous location where exception was thrown ---
06-16 14:20:56.190 E/mono    ( 4556):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
06-16 14:20:56.190 E/mono    ( 4556):   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
06-16 14:20:56.190 E/mono    ( 4556):   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
06-16 14:20:56.190 E/mono    ( 4556):   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
06-16 14:20:56.190 E/mono    ( 4556):   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535 
06-16 14:20:56.190 E/mono    ( 4556):   at Xamarin.Android.Net.AndroidClientHandler+<ProcessRequest>c__async1.MoveNext () [0x000b3] in /Users/builder/data/lanes/3204/804c6cb7/source/monodroid/src/Mono.Android/src/Xamarin.Android.Net/AndroidClientHandler.cs:207 
06-16 14:20:56.190 E/mono    ( 4556): --- End of stack trace from previous location where exception was thrown ---
06-16 14:20:56.190 E/mono    ( 4556):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
06-16 14:20:56.190 E/mono    ( 4556):   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task tas
06-16 14:20:56.190 E/mono-rt ( 4556): [ERROR] FATAL UNHANDLED EXCEPTION: Java.Net.ProtocolException: unexpected end of stream
06-16 14:20:56.190 E/mono-rt ( 4556):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
06-16 14:20:56.190 E/mono-rt ( 4556):   at Java.Interop.JniEnvironment+InstanceMethods.CallIntMethod (JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00085] in /Users/builder/data/lanes/3204/804c6cb7/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:11484 
06-16 14:20:56.190 E/mono-rt ( 4556):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualInt32Method (System.String encodedMember, IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00031] in /Users/builder/data/lanes/3204/804c6cb7/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:206 
06-16 14:20:56.190 E/mono-rt ( 4556):   at Java.Net.HttpURLConnection.get_ResponseCode () [0x00000] in /Users/builder/data/lanes/3204/804c6cb7/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Java.Net.HttpURLConnection.cs:505 
06-16 14:20:56.190 E/mono-rt ( 4556):   at Xamarin.Android.Net.AndroidClientHandler.DoProcessRequest (System.Net.Http.HttpRequestMessage request, Java.Net.HttpURLConnection httpConnection, CancellationToken cancellationToken) [0x000a0] in /Users/builder/data/lanes/3204/804c6cb7/source/monodroid/src/Mono.Android/src/Xamarin.Android.Net/AndroidClientHandler.cs:228 
06-16 14:20:56.190 E/mono-rt ( 4556):   at Xamarin.Android.Net.AndroidClientHandler+<ProcessRequest>c__async1+<ProcessRequest>c__AnonStorey2.<>m__0 () [0x00000] in /Users/builder/data/lanes/3204/804c6cb7/source/monodroid/src/Mono.Android/src/Xamarin.Android.Net/AndroidClientHandler.cs:207 
06-16 14:20:56.190 E/mono-rt ( 4556):   at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x00012] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/threading/Tasks/Future.cs:680 
06-16 14:20:56.190 E/mono-rt ( 4556):   at System.Threading.Tasks.Task.Execute () [0x00016] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502 
06-16 14:20:56.190 E/mono-rt ( 4556): --- End of stack trace from previous location where exception was thrown ---
06-16 14:20:56.190 E/mono-rt ( 4556):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
06-16 14:20:56.190 E/mono-rt ( 4556):   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
06-16 14:20:56.190 E/mono-rt ( 4556):   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
06-16 14:20:56.190 E/mono-rt ( 4556):   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
06-16 14:20:56.190 E/mono-rt ( 4556):   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535 
06-16 14:20:56.190 E/mono-rt ( 4556):   at Xamarin.Android.Net.AndroidClientHandler+<ProcessRequest>c__async1.MoveNext () [0x000b3] in /Users/builder/data/lanes/3204/804c6cb7/source/monodroid/src/Mono.Android/src/Xamarin.Android.Net/AndroidClientHandler.cs:207 
06-16 14:20:56.190 E/mono-rt ( 4556): --- End of stack trace from previous location where exception was thrown ---
06-16 14:20:56.190 E/mono-rt ( 4556):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/1196/3e934261/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
06-16 14:20:56.190 E/mono-rt ( 4556):   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threadin


** XAMARIN INFO *************************************************************

Microsoft Visual Studio Professional 2015
Version 14.0.25123.00 Update 2
Microsoft .NET Framework
Version 4.6.01038

Xamarin   4.2.0.21 (a532c82)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   6.1.99.224 (804c6cb)
Visual Studio extension to enable development for Xamarin.Android.

Xamarin.iOS   9.9.0.719 (3afb4af)
Visual Studio extension to enable development for Xamarin.iOS.

OS Name	Microsoft Windows 10 Enterprise
Version	10.0.10586 Build 10586
Comment 11 Marek Habersack 2016-06-20 10:23:11 UTC
This commit https://github.com/xamarin/xamarin-android/commit/5db477df1a5164dc017a056e9e8d0aefbc7cbfb1 should fix the reported issue.

Guys, please take the fixed handler source from https://github.com/xamarin/xamarin-android/blob/master/src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.cs and use it as a workaround until new version of XA is released from the open-source repo, thanks!

Thanks @alex for the fix!

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