Bug 51674 - HTTPS request with proxy with authentication throws error. Same HTTP request works OK.
Summary: HTTPS request with proxy with authentication throws error. Same HTTP request ...
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 7.1 (C9)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2017-01-20 22:24 UTC by JeremyH
Modified: 2017-08-23 21:10 UTC (History)
4 users (show)

Tags: bb
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 JeremyH 2017-01-20 22:24:29 UTC
I have latest Xamarin Studio with Beta branch set:
Xamarin Studio v6.2
Xamarin Android v7.1.0.19
SDK Tools version 25.2.5
SDK Platform tools: 25.0.3
SDK Build Tools: 25.0.2
Java SDK

Here's the sample code:

    public class MainActivity : Activity
        protected override void OnCreate(Bundle bundle)

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            Task.Factory.StartNew(() =>

        void RunRequestAndroid()
            Authenticator.SetDefault(new Authenticator1());

            var url = new URL("https://www.google.com/");

            // Set proxy with authentication (I'm using Fiddler setup on local machine)
            var urlConnection = (HttpURLConnection)url.OpenConnection(new Proxy(Proxy.Type.Http, new InetSocketAddress("", 8888)));

                var s = urlConnection.InputStream;
            catch (Exception ex)

        public class Authenticator1 : Authenticator
            protected override PasswordAuthentication PasswordAuthentication
                    return new PasswordAuthentication("johndoe", "1234567890".ToCharArray());

The exception is Java.IO.EOFException.

Note that if I change to non-secure URL, it works OK: 
var url = new URL("http://www.google.com/");

And in order to be sure the proxy is working, I made a .NET C# console app, which works OK with HTTPS:

        static void Main(string[] args)
                IWebProxy proxy = new WebProxy("");
                proxy.Credentials = new NetworkCredential("johndoe", "1234567890");
                WebRequest.DefaultWebProxy = proxy;

                var req = WebRequest.CreateHttp("https://www.google.com");
                var s = req.GetResponse();
            catch (Exception ex)


The call stack when error is thrown:

Java.IO.EOFException: Exception of type 'Java.IO.EOFException' was thrown.
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/4009/3d959b66/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
  at Java.Interop.JniEnvironment+InstanceMethods.CallObjectMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00085] in /Users/builder/data/lanes/3511/501e63ce/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:11283 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00031] in /Users/builder/data/lanes/3511/501e63ce/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:350 
  at Java.Net.URLConnection.get_InputStream () [0x00000] in /Users/builder/data/lanes/4009/3d959b66/source/monodroid/src/Mono.Android/platforms/android-25/src/generated/Java.Net.URLConnection.cs:733 
  at TestXamarinHttpRequestProxy.MainActivity.RunRequestAndroid () [0x0003d] in C:\Shared\TestXamarinHttpRequestProxy\TestXamarinHttpRequestProxy\MainActivity.cs:61 
  --- End of managed Java.IO.EOFException stack trace ---
	at com.android.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:98)
	at com.android.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:202)
	at com.android.okhttp.Connection.makeTunnel(Connection.java:1564)
	at com.android.okhttp.Connection.upgradeToTls(Connection.java:1282)
	at com.android.okhttp.Connection.connect(Connection.java:1225)
	at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:395)
	at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:298)
	at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:399)
	at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:349)
	at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:203)
	at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
	at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:25)
Comment 1 Tom Opgenorth 2017-06-27 18:19:37 UTC
Thank you for taking the time to submit the bug. We are unable to reproduce this issue. Please attach a reproduction to the bug by starting with a clean Xamarin.Android project and adding just the code necessary to demonstrate the issue.

(There have been some changes to the TLS stack on Xamarin.Android; I suspect those changes might have fixed this issue.)
Comment 2 Cody Beyer (MSFT) 2017-08-23 21:10:17 UTC
Because we have not received a reply to our request for more information we are closing this issue. If you are still encountering this issue, please reopen the ticket with the requested information. Thanks!