Bug 44025 - FTP download issue with IPv6
Summary: FTP download issue with IPv6
Alias: None
Product: iOS
Classification: Xamarin
Component: BCL Class Libraries ()
Version: XI 9.99 (iOS 10 previews)
Hardware: Macintosh Mac OS
: High normal
Target Milestone: (C9)
Assignee: Alexander Köplinger [MSFT]
Depends on:
Reported: 2016-09-06 15:01 UTC by Xavier Bailliet
Modified: 2017-02-02 09:04 UTC (History)
7 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 Xavier Bailliet 2016-09-06 15:01:09 UTC
FTP download code does not work on NAT64 network (testing for Apple store).

I connect my iphone to my mac set as a NAT64 router, run the code below to test the app with IPv6 and I get this error:System.Net.WebException: Cannot open passive data connection.


//Create A 2MB Cache Buffer
byte[] Buffer = new byte[2048];
int FileLenght = 0;

//Create An FTP Client Request
FtpWebRequest Request = (FtpWebRequest)WebRequest.Create(FTP);
Request.Method = WebRequestMethods.Ftp.DownloadFile;

//Use A Login Credential
//Request.Credentials = new NetworkCredential("USER", "PASS");

//Receive An Answer From Server
FtpWebResponse Response = (FtpWebResponse)Request.GetResponse();
Stream ResponseStream = Response.GetResponseStream();

//Write The File To The SDCARD
StreamWriter Output = new StreamWriter(Local, false);

//Store On Buffer And Write TO SDCARD
while ((FileLenght = ResponseStream.Read(Buffer, 0, Buffer.Length)) > 0)
	for (int i = 0; i < FileLenght; i++)

//Close File Stream Writer

//Close Connection Request

The error only happen with NAT64 network, I tested the NAT64 network with the same code on an android device and other apps on the market with success.
Comment 1 Vincent Dondain [MSFT] 2016-09-08 14:39:02 UTC
Hi, I could successfully reproduce this issue with the following versions of our products: https://gist.github.com/VincentDondain/4edea68e968b73cd3f7c6deb5b10e6d4

To do that I created this sample app: https://www.dropbox.com/s/ptgb09wpn7hdag3/Bug44025.zip?dl=0 (it's using a dummy ftp that you can access and tries to download a readme file).

To simulate a NAT64 network I used this guide (section "Test for IPv6 DNS64/NAT64 Compatibility Regularly") https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html

Here is the exception we're getting: https://gist.github.com/VincentDondain/32515f43df9894f3d6a5878ca5f89454 [on (FtpWebResponse)request.GetResponse ()]

Full build logs: https://gist.github.com/VincentDondain/910c49022d770cd1f00a337ef7a38f34
Comment 2 Xavier Bailliet 2016-09-09 09:16:22 UTC
Hi Vincent,

Because of this issue my app has been rejected by apple and I have my customer asking when the app will be released? Do we have an ETA for this bug fix? or failing that could you just let me know what are the next steps likely to be?

Thank you,

Comment 3 Vincent Dondain [MSFT] 2016-09-26 16:03:44 UTC

This is not a trivial issue in the BCL. I cannot give you any information with regard to when this will be fixed.

I'd recommend you use the native APIs in order to submit your app (NSUrlConnection and NSUrlDownload in the case of iOS).

Comment 4 Alexander Köplinger [MSFT] 2016-10-12 18:26:28 UTC
I implemented the BCL support in this PR: https://github.com/mono/mono/pull/3762
Comment 5 Alexander Köplinger [MSFT] 2016-10-13 18:37:01 UTC
Merged to mono master and mono-4.8.0-branch. Thanks!
Comment 6 Sebastien Pouliot 2016-10-13 19:38:32 UTC
QA: XI/XM won't have the fix available to confirm before https://github.com/xamarin/xamarin-macios/pull/991 is merged.
Comment 7 Sebastien Pouliot 2016-10-14 15:35:41 UTC
QA: https://github.com/xamarin/xamarin-macios/pull/991 did the bump so any package after 84e9975e41f48e2444d233eda64112377856276c can be used to test
Comment 8 Danish Akhtar 2017-02-02 09:04:54 UTC
Reproduce status:
I am also able to reproduce this issue, after following Comment 1, with X.iOS,  application throws System.Net.WebException. 

Here is the screencast for the same: https://www.screencast.com/t/WjKFWUkI

Verification Status:
I connect my iphone to my mac set as a NAT64 router and observed that application is launched and running successfully on iOS device with C9 X.iOS & Master X.iOS 

Hence closing this issue.