Issue
I've used Apache FTP Client library as the document says. I've done like this :
FTPClient ftp = new FTPClient();
String server = "172.166.166.17";
ftp.connect(server);// or ftp.connect(server,21)
System.out.println("Connected to " + server + ".");
System.out.print(ftp.getReplyString());
It works fine in dev environment but I get the following error in live environment:
java.net.UnknownHostException: 172.166.166.17 : Name or service not known
I asked the network team to check the communication and they responded that because the Telenet and Linux FTP command working, they can't do more.
Here is their command and their responses :
$ ftp 172.166.166.17
connected to 172.166.166.17(172.166.166.17).
220 Welecome to IIP FTP service!
I've used this library in many projects and never faced this error. I'm wondering what's the cause of this problem and how can I fix that.
Solution
For those who may have a similar problem, I find out 172.166.166.17 is not the actual IP and the network team NATed ( Network address translation) the actual IP to another. So by pointing to the actual IP the problem got resolved.
If anyone has an explanation for this problem I will consider it as an answer.
Answered By - Mostafa Answer Checked By - Clifford M. (WPSolving Volunteer)