Bug 46696 - WebRequest ipv6 environment does not work with ipv4 address
Summary: WebRequest ipv6 environment does not work with ipv4 address
Alias: None
Product: iOS
Classification: Xamarin
Component: BCL Class Libraries ()
Version: XI 10.4 (C9)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2016-11-10 10:13 UTC by giga_tobi
Modified: 2017-01-23 20:19 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:

Description giga_tobi 2016-11-10 10:13:12 UTC
Steps to reproduce:

Setup ipv6 environment, for example by following: https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html#//apple_ref/doc/uid/TP40010220-CH213-SW1

Execute the following code in a Xamarin iOS Project on a device in the ipv6 network:

public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
			// Override point for customization after application launch.
			// If not required for your application you can safely delete this method

			var ip = "";
			return true;

		public async void testCalls(string ip) { 
			await testClient(ip);
			await testReq(ip);

		public async Task testClient(string ip)
			HttpClient a = new HttpClient(new NSUrlSessionHandler());
			string result = await a.GetStringAsync(ip);

		public async Task testReq(string ip)
			var req = WebRequest.Create(ip);
			WebResponse response = await req.GetResponseAsync();
			var dataStream = response.GetResponseStream();
			StreamReader reader = new StreamReader(dataStream);
			var responseFromServer = await reader.ReadToEndAsync();

The result is that HttpClient works fine, but WebRequest fails with Exception:
System.Net.WebException: Error: ConnectFailure (Network is unreachable) ---> System.Net.Sockets.SocketException: Network is unreachable

I guess it is because we can pass NSURLSessionHandler to HttpClient but not the WebRequest. However i think both of the calls should work.
Comment 1 Marek Safar 2016-12-21 11:50:38 UTC
I cannot reproduce the issue on simulator all methods work for me connecting to "http://[0:0:0:0:0:ffff:d976:a850]".

Are you hitting this issue on device only?
Comment 2 Vincent Dondain [MSFT] 2017-01-23 20:19:40 UTC
We have not received the requested information. If you are still experiencing this issue please provide all the requested information and re-open the bug report. Thanks!