仍然没有答案。任何和所有的帮助表示赞赏!
我正在使用 Apache Commons-Net3.1 并试图让 FTPS 工作。当我尝试连接时,控制台中出现以下错误:
---编辑:代码和错误更新---
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:171)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:192)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:285)
我确定我只是没有正确设置它。这是我的代码。任何正确方向的观点都将不胜感激。(顺便说一下,我正在尝试通过端口 990 连接)。“client.connect(ftpHost);”行的代码错误
import org.apache.commons.net.ftp.FTPSClient;
import java.io.IOException;
import java.io.FileOutputStream;
public class MyFTP {
public void downloadFTP(){
FTPSClient client = new FTPSClient(false);
FileOutputStream fos = null;
client.setTrustManager(TrustManagerUtils.getAcceptAllTrustManager());
try {
client.connect(ftpHost);
client.enterLocalPassiveMode();
client.login(ftpUser, ftpPassword);
String filename = "liveGUIfile.txt";
fos = new FileOutputStream(filename);
client.retrieveFile("/root/Desktop/" + filename, fos);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fos != null) {
fos.close();
}
client.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}