Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
Created attachment 18032 [details]
This is a bit of an odd issue, so bear with me.
If this sample app is launched with a network connection and the button is tapped to send a request, the request succeeds. If then Airplane mode is enabled, the request of course fails, but upon disabling Airplane mode the next request sent succeeds right away.
In contrast, if after app launch the first request is sent with Airplane mode enabled then the request fails with a NameResolutionFailure exception for obvious reasons (no network). However if you then disable Airplane mode and send new request, it still fails and will continue to fail with NameResolutionFailure exception for a couple of minutes, but eventually will succeed.
This is a regression. Using XA 188.8.131.52 the above does not occur and the first request sent immediately after network connection is restored succeeds.
## Steps to reproduce
1. Open the attached sample app.
2. Deploy to Android device or emulator. (Tested with Google emulator Nexus 5 marshmallow)
3. Stop the app from xamarin studio to detach the debugger (if you don't do this there are issues when you turn on airplane mode with the debugger and the app hangs)
4. Enable Airplane Mode (don't do this before deploying or the debugger won't be able to attach and the app won't launch)
5. Launch the app from the simulator.
6. Tap the button.
7. Button will show NameResolutionFailure message.
8. Disable Airplane mode
9. Tap the button.
Expected result: button text will display the ContentType of the response (text/HTML)
Actual result: button text still shows NameResolutionFailure exception.
As stated, eventually if you keep tapping the button after step 9 above, the request will work after a couple of minutes. And again this does not happen with XA 184.108.40.206
I also tested that it was not an issue with building against Android SDK version 6.0 vs 7.0. And that the issue is not affected by which HttpClientHandler is used. The attached sample is using a HttpWebRequest however I have another customer who reported the same issue and they were using HttpClient and I confirmed that their test project also worked with XA 220.127.116.11.
The only difference between a version of the app that works and the version of the app that does not is the Xamarin Android version, IOW I was able to only install XA 18.104.22.168 into the existing Cycle 8 install and then the attached test project and the other clients test project (not attached) worked as expected.
As an additional note, if the first request is sent without Airplane mode enabled (i.e. there is network connection) then the request succeeds, of course, but if you then enable Airplane mode and send the request, it fails with a "No Network Connection" error and if you then turn off Airplane mode again, the next request succeeds right away.
I initially I thought this was a DNS caching issue and was able to resolve in another customers test case by making sure no request was sent when the network was not available. I found some posts that Android caches bad DNS queries and thought that was the issue. But upon discovering that XA 22.214.171.124 does not display this issue, I reconsidered. Also, upon further reading and investigation, I found out that the bad DNS query should only be cached for 10 seconds while the NameResolutionFailure exception persists for a couple of minutes after restoring network connection.
=== Xamarin Studio Enterprise ===
Version 6.1.1 (build 15)
Installation UUID: ceaba76c-db06-4fbd-b326-f69ea53c3e01
Mono 4.6.1 (mono-4.6.0-branch-c8sr0/ef43c15) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Package version: 406010005
=== NuGet ===
=== Xamarin.Profiler ===
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Apple Developer Tools ===
Xcode 8.0 (11246)
=== Xamarin.Android ===
Version: 126.96.36.199 (Visual Studio Enterprise)
Android SDK: /Users/jongoldberger/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
4.0.3 (API level 15)
4.1 (API level 16)
4.2 (API level 17)
4.3 (API level 18)
4.4 (API level 19)
5.0 (API level 21)
5.1 (API level 22)
6.0 (API level 23)
7.0 (API level 24)
SDK Tools Version: 25.2.2
SDK Platform Tools Version: 24.0.3
SDK Build Tools Version: 24.0.3
Java SDK: /usr
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
Android Designer EPL code available here:
=== Xamarin Android Player ===
Location: /Applications/Xamarin Android Player.app
=== Xamarin.iOS ===
Version: 10.0.1.10 (Visual Studio Enterprise)
Build date: 2016-10-03 15:18:44-0400
=== Xamarin.Mac ===
Version: 188.8.131.52 (Visual Studio Enterprise)
=== Xamarin Inspector ===
Build date: Thu, 18 Aug 2016 17:46:46 GMT
=== Build Information ===
Release ID: 601010015
Git revision: fa52f02641726146e2589ed86ec4097fbe101888
Build date: 2016-09-22 08:03:02-04
Xamarin addins: 75d65712af93d54dc39ae4c42b21dfa574859fd6
Build lane: monodevelop-lion-cycle8-sr0
=== Operating System ===
Mac OS X 10.12.0
Darwin Jons-MacBook-Pro.local 16.0.0 Darwin Kernel Version 16.0.0
Mon Aug 29 17:56:20 PDT 2016
=== Enabled user installed addins ===
Xamarin Inspector 0.10.0.0
I have a customer saying this is also reproducible on iOS. Both are using native handlers for HttpClient
Upon further testing, this is an issue in mono. I could reproduce this issue in a Xamarin iOS app as well as a Mono console app. I will file new bug reports and link back to this one.
*** This bug has been marked as a duplicate of bug 45761 ***
The workaround for this would seem to be to test for network connectivity before sending your request, and to use a different url to test for connectivity than the one you need to send requests to.
You can use the Connectivity plugin for this: https://www.nuget.org/packages/Xam.Plugin.Connectivity/
That is not a workaround that is acceptable for an enterprise customer.