1

I'm building an app with Xamarin Forms. I have no issues with Android, but when I attempt to simulate or deploy the iOS app, my HttpClient can't seem to connect to the server. After the timeout expires, I get a TaskCanceledException.

The HttpClient is actually used in a separate project that is referenced by the iOS app, if that matters. Here's my usage:

string serviceUri = service + methodName;

            HttpRequestMessage request = new HttpRequestMessage(methodRequestType, serviceUri)
            {
                Content = new StringContent(content, Encoding.UTF8, "application/json")
            };

            HttpResponseMessage response = await _client.SendAsync(request).ConfigureAwait(false);
            string returnString = await response.Content.ReadAsStringAsync();
            return returnString;

I'm not using any waits or accessing .Result, as I've seen many people try that don't understand async operations.

I've seen older posts (circa 2013) where the wrong HttpClient is used. Is this still an issue in current releases? I've also tried changing the HttpClient implementation in the iOS project settings, to no avail.

Thanks in advance!

3
  • Are you connecting to a https or http source? If http have you set ATS exceptions? Commented Apr 24, 2017 at 5:44
  • It is a https source, and I've just retested the endpoint with ssllabs.com/ssltest and it reported no issue with ATS. Commented Apr 24, 2017 at 6:13
  • are you able to connect to any other webpage? Commented May 2, 2017 at 20:32

1 Answer 1

2

The issue was an invalid Deployment Target - It was set to "80" instead of "8.0

In come cases, the build server does not communicate this invalidity back to your machine - hence why it took so long to notice it!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.