I trie to connect to a remote server with the FTP from Apache commons library. But i can't connect to this server..i got the exception:
java.net.ConnectException: Connection timed out: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at org.apache.commons.net.SocketClient.connect(SocketClient.java:188) at org.apache.commons.net.SocketClient.connect(SocketClient.java:209) at de.download.Info4c.start(Info4c.java:95) at de.download.Info4c.main(Info4c.java:67)
This is my code:
FTPSClient client = new FTPSClient(false);
client.connect("<IP>",990);
int reply = client.getReplyCode();
if (FTPReply.isPositiveCompletion(reply)) {
if(client.login(user, pass)){
// Set protection buffer size
client.execPBSZ(0);
// Set data channel protection to private
client.execPROT("P");
// Enter local passive mode
client.enterLocalPassiveMode();
}
}
ping <IP>
to test if the server exists. If it responds, check the port as @duffymo suggests. Otherwise your issue is that from your PC, you cannot see that server. That doesn't necessarily mean that the server is off! It could be firewall or other factors. – Neil-Djava.net.preferIPv4Stack=true
– CroWell