Skip to content
Prev 50839 / 63421 Next

download.file() on ftp URL fails in windows with default download method

Hi David,

----- Original Message -----
Thanks!

I have just been looking at this issue with Martin Morgan. We found that if we "or" the additional flag INTERNET_FLAG_PASSIVE on line 1012 of src/modules/internet/internet.c (R-3.2 branch, last changed in r68393)
that the ftp connection works.

Further investigation reveals that in a passive ftp connection, certain ports on the client need to be open.
This machine is in the Amazon cloud so it was easy to open the ports. But we still have a problem and I believe it's that the wrong IP address is being sent to the server (on an AWS machine, the machine thinks of itself as having one IP address, but that is a private address that is valid inside AWS only). 

Here's a curl command line that gets around this by sending the correct address (or hostname):

curl --ftp-port myhostname.com ftp://ftp.ncbi.nlm.nih.gov/genomes/ASSEMBLY_REPORTS/All/GCF_000001405.13.assembly.txt

Curl normally uses passive mode which is why it works, but the --ftp-port switch tells it to use active mode with the specified ip address or hostname.

So I'm not sure where we go from here. One easy fix is just to add the INTERNET_FLAG_PASSIVE flag as described above. Another would be to first check if active mode works, and if not, use passive mode. 

Dan