作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 ftp4j 库来实现我的 FTP 客户端,但是我尝试连接的服务器仅在 Activity 模式下接受连接。
因此,当我尝试列出远程文件时,我得到:
ERROR : Error in Connecting to Remote Machine... Hence exitting...
it.sauronsoftware.ftp4j.FTPException [code=501, message= Server cannot accept argument.]
at it.sauronsoftware.ftp4j.FTPClient.openActiveDataTransferChannel(FTPClient.java:3600)
at it.sauronsoftware.ftp4j.FTPClient.openDataTransferChannel(FTPClient.java:3551)
at it.sauronsoftware.ftp4j.FTPClient.listNames(FTPClient.java:2335)
at com.npap.network.TranferFileFtp4j.listRemoteFilesFtp1(TranferFileFtp4j.java:999)
这是代码:
...
//connect to server method - in active mode!
ftpClient = Ftp4jUtility.connect1(SERVER_MACHINE, PORT, SERVER_USERNAME, SERVER_PASSWORD);
try {
ftpClient.changeDirectory(config.getFtpRemoteFolderReports());
log.info("Changed directory to: " + config.getFtpRemoteFolderReports());
} catch (FTPException | FTPIllegalReplyException | IOException | IllegalStateException e) {
e.printStackTrace();
}
String[] filesList = ftpClient.listNames();
for(String f: filesList) {
log.info("fetched file: " + f);
tmpAllRemoteFiles.add(f);
}
在主动模式下连接时有什么方法可以列出远程文件吗?
最佳答案
是的,您可以在 Activity 模式下使用.listNames()
。
问题可能是服务器无法连接回您的客户端以打开数据连接。您必须在本地防火墙(如果有)上打开 FTP 数据连接范围的端口,并在 NAT(如果有)上路由传入连接。
配置主动模式FTP比较麻烦,很少使用。
了解(我的)关于所需文章 network configuration in respect to FTP active mode .
501 错误代码来自 FTP 服务器(可能是 IIS)。如果您在 google 上搜索“501 Server 无法接受参数”,您会发现很多类似的问题。
你的代码没有任何问题。要么是网络配置问题,要么是服务器端问题。
关于Java ftp4j - 以 amn 主动模式连接时列出 FTP 服务器中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28705328/
我不确定这是否适合 stackoverflow,但我不知道还有什么地方可以问。我正在研究用于证明需求规范一致性的 B 方法,但在指定操作的前提条件时我对逻辑数学符号有疑问。 简化原始问题,我有一个变量
我正在使用 ftp4j 库来实现我的 FTP 客户端,但是我尝试连接的服务器仅在 Activity 模式下接受连接。 因此,当我尝试列出远程文件时,我得到: ERROR : Error in Conn
我是一名优秀的程序员,十分优秀!