Created attachment 18152 [details]
This is a duplicate of Mono bug #45761. Submitting this and marking as duplicate to help anyone searching for this issue on iOS.
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 XI 220.127.116.11 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 and set the iOS project as the startup project.
2. Deploy to iOS device. (turning on Airplane mode on simulator does not interrupt network connection)
3. Enable Airplane Mode (don't do this before deploying or the debugger won't be able to attach and the app won't launch)
4. Tap the "Send Request" button.
5. Label will show NameResolutionFailure message.
6. Disable Airplane mode
7. Tap the "Send Request" button.
Expected result: label text will display the ContentType of the response (text/HTML)
Actual result: label text still shows NameResolutionFailure exception.
As stated, eventually if you keep tapping the button after step 7 above, the request will work after a couple of minutes. And again this does not happen with XI 18.104.22.168
The attached sample is using a HttpWebRequest however I have another customer who reported the same issue and they were using HttpClient.
The only difference between a version of the app that works and the version of the app that does not is the Xamarin iOS version, IOW I was able to only install XI 22.214.171.124 into the existing Cycle 8 install and then the attached test project 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.
=== 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
*** This bug has been marked as a duplicate of bug 45761 ***
BAD: XI 10.0.1.10
BAD: XI 10.0.1.8
BAD: XI 10.0.0.6
GOOD: XI 184.108.40.206
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/
Created attachment 18157 [details]
Correct Test Project
I accidentally uploaded the wrong test project. this is the correct one.