Bug 17583 - HttpClient.GetStringAsync(url) generates WebException: Error: ConnectFailure (XA 4.12 in release mode only)
Summary: HttpClient.GetStringAsync(url) generates WebException: Error: ConnectFailure ...
Status: RESOLVED DUPLICATE of bug 17397
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.12.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2014-02-03 20:17 UTC by Jon Goldberger [MSFT]
Modified: 2014-02-04 14:37 UTC (History)
2 users (show)

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

Test Project (15.64 KB, application/zip)
2014-02-03 20:17 UTC, Jon Goldberger [MSFT]

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:

Comment 1 Jon Goldberger [MSFT] 2014-02-03 20:18:18 UTC
I'm running the latest alpha:

Xamarin.Android 4.12.00012 (56127394)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS 1.10.39 (e0334707)
Visual Studio extension to enable development for Xamarin.iOS

And the following code sample works on in debug mode, but doesn't work in release.

using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Android.App;
using Android.Content;
using Android.Net;
using Android.Runtime;
using Android.Util;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace ConnectionTest
[Activity(Label = "ConnectionTest", MainLauncher = true, Icon = "@drawable/icon")]
public class Activity1 : Activity
int count = 1;

protected override void OnCreate(Bundle bundle)

// Set our view from the "main" layout resource

// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button>(Resource.Id.MyButton);

button.Click += async (sender, args) =>
if (await DownloadFromHttps())
button.Text = "OK!";
button.Text = "Broken";

public async Task<bool> DownloadFromHttps()
string url = "https://tirone.accesscontrol.windows.net/v2/metadata/IdentityProviders.js?protocol=javascriptnotify&realm=urn://tirone/api/live&version=1.0";
HttpClient client = new HttpClient();
string result = await client.GetStringAsync(url);
Log.Error("OK", result);
return true;
catch (Exception err)
Log.Error("download", err.ToString());
return false;

Comment 2 Jon Goldberger [MSFT] 2014-02-03 20:22:03 UTC
Comment 1 is from the case file. The code in comment 1 is in the attached sample project.

After some investigation, I found that either setting the Linker to "Don't link" and/or checking "Use shared runtime" in the Release configuration makes the exception go away.
Comment 3 Jon Goldberger [MSFT] 2014-02-03 20:23:39 UTC
More from the case:
I'm using vs2013 with update 1 applied, and the code will work if its pasted into the default android app, and at the http package via nuget.

Remember that it only breaks in release mode, and works fine in debug strangely.

I think the issue is something to do with DNS lookup, but the error doesn't really give me much more.

Running the same code in stable works fine in both release and debug mode.

Let me know if you need anything more.
Comment 4 Jonathan Pryor 2014-02-04 14:37:18 UTC
This is probably a dupe of #17397: SSL is busted when the linker is enabled.

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