Akli
Akli

Reputation: 1539

Xamarin : HttpClient fails with some URLs (TaskCanceledException)

In my Xamarin.Forms project, System.Net.Http.HttpClient fails with some URLs. I've got an obscure message :

System.Threading.Tasks.TaskCanceledException: A task was canceled.

I don't know how to retrieve the exact message...

Examples :

HttpClient works with :

http://stackoverflow.com

https://www.nytimes.com/

HttpClient fails with (only in Xamarin, works elsewhere : WPF, ConsoleApp... etc) :

http://www.leparisien.fr

https://www.google.fr/

EDIT 1: From Xamarin.Android I have the same behaviour, whether I use HttpClient , WebClient or Restsharp.

Upvotes: 0

Views: 588

Answers (2)

Akli
Akli

Reputation: 1539

The behaviour happens only with Visual Studio Emulator for Android, When I deploy on a google Emulator or a real device I don't have that problem. Weird cause when I use compiled code from Android Studio with these URLs it works.

I also had other problems with other URLs, I had to use ModernHttpClient.

Upvotes: 1

Anastasios Moraitis
Anastasios Moraitis

Reputation: 388

I strongly recommend to use Flurl. I am using it in every project, with no problem! Also, provide more informations about your error!

Upvotes: 0

Related Questions