HttpClient - Xamarin Android - MvvmCross
Asked Answered
G

1

3

I've been developing an application for Android using Xamarin with MvvmCross and everything has been going fine, me and my team were able to develop the solution and this week we decided to make the final adjustments and to test the application in other environments. During the tests I had a huge problem with the Android solution. In the working environment everything was working fine but when I tried to test the application at home the application stopped working. I checked what was happening and I found out that the HttpClient was not being able to complete a call to the server and throwing the following exception:

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter`1[System.Net.Http.HttpResponseMessage].GetResult () [0x00000] in <filename unknown>:0
at System.Net.Http.HttpClientHandler+<SendAsync>c__async0.MoveNext () [0x00000] in <filename unknown>:0

I searched for a solution in Google and I found a similar problem in the Xamarin Forum http://forums.xamarin.com/discussion/30152/error-nameresolutionfailure (Jefimijana post) and one of the answers was about network misconfiguration wich seems odd to me because all other applications seem to work just fine. I tested the WPF application connected to the same wifi to check if there was any problem but it worked just fine. So there I found myself with an even bigger problem, I cannot tell the user that he has to readjust his wifi connection when all other applications work properly and I cannot have my application not working with some wifis for no apparent reason. So my question is, is there a solution for this problem? Is this some sort of Xamarin problem related to the HttpClient? Or is this an Android problem?

  • The device I've been testing with is a Samsung Galaxy Tab 3

Thanks,

Gomuti answered 23/2, 2015 at 0:5 Comment(1)
You really need to provide some sample code. I have no idea where to even suggest what might be going wrong.Extern
S
7

Unfortunately, you haven't provided more information about what you are trying to do, but I can confirm that we are seeing similar buggy behavior in our Xamarin.Android Apps.

The Mono Network Stack on Android has at least two problems (as of Feb 2015) that we are experiencing, so you are not alone:

The best workaround I can recommend to you at the moment is to use ModernHttpClient, which is a HttpClientHandler implementation that uses a native API and thus doesn't involve the mono Network stack (plus it's considerably faster too).

Speciation answered 23/2, 2015 at 7:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.