FTP server is returning inaccessible passive IP address
Posted by Van Glass on 23 May 2008 11:40 PM
You may come across an FTP server that is improperly configured such that when the FTP client sends the PASV command, the server responds with a LAN (local area network) address, rather than the Internet addressable IP address. The result is that the client will time-out when attempting to establish a passive connection. |
To resolve this issue you can do one of the following:
a. Reconfigure server so that it returns the proper IP address in response to PASV client command.
b. In the event that (a) is not possible, you can instruct the client to use the IP address of the FTP server hostname by using the Ftp.setNATAddress method. This will force the client to ignore the IP address returned by the server in response to PASV command and use the IP address provided in setNATAddress method.
For example, assuming a FTP hostname of ftp.myhost.com, you may try the following:
// get IP address for hostname
java.net.InetAddress inetAdd = java.net.InetAddress.getByName("ftp.myhost.com");
// establish connection
// set NAT address