简体   繁体   中英

HttpClient - Xamarin Android - MvvmCross

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,

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM