【问题标题】:FTP Connection Timed out 421 : parser errorFTP 连接超时 421:解析器错误
【发布时间】:2013-03-26 10:22:12
【问题描述】:

问题已被编辑。我正在尝试列出 FTP 目录中的所有文件 - 虽然代码在正常的 Netbeans 项目中运行时运行良好,但在 Maven 项目中使用相同的代码时,它会导致 connection timed out 421 。我怎样才能摆脱这个?

代码:

FTPClient ftpClient = new FTPClient();
ftpClient.connect(host, 21);
ftpClient.login(user, pass);
ftpClient.enterLocalPassiveMode();
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
ftpClient.configure(conf);
inputStream = FTPUtil.downloadSingleFile(ftpClient, filePath);
ftpClient.list();                         // It works
ftpClient.listNames("/");                 // It works
ftpClient.changeWorkingDirectory("/");    // It works
FTPFile[] files = ftpClient.listFiles("/");// It hangs and stops 421 connection timed out

FileZilla 日志是:-

    (000370)04-04-2013 16:04:32 - (not logged in) (127.0.0.1)> Connected, sending welcome message...
    (000370)04-04-2013 16:04:32 - (not logged in) (127.0.0.1)> 220 ftp connection started...
    (000370)04-04-2013 16:04:32 - (not logged in) (127.0.0.1)> USER raja
    (000370)04-04-2013 16:04:32 - (not logged in) (127.0.0.1)> 331 Password required for raja
    (000370)04-04-2013 16:04:32 - (not logged in) (127.0.0.1)> PASS ****
    (000370)04-04-2013 16:04:32 - raja (127.0.0.1)> 230 Logged on
    (000370)04-04-2013 16:04:32 - raja (127.0.0.1)> TYPE I
    (000370)04-04-2013 16:04:32 - raja (127.0.0.1)> 200 Type set to I
    (000370)04-04-2013 16:04:32 - raja (127.0.0.1)> PASV
    (000370)04-04-2013 16:04:32 - raja (127.0.0.1)> 227 Entering Passive Mode (127,0,0,1,237,187)
    (000370)04-04-2013 16:04:32 - raja (127.0.0.1)> SYST
    (000370)04-04-2013 16:04:32 - raja (127.0.0.1)> 215 UNIX emulated by FileZilla
    (000366)04-04-2013 16:04:33 - raja (127.0.0.1)> 421 Connection timed out.

客户端例外是:-

【问题讨论】:

  • 那么您的 filezilla 和您的软件有问题吗?
  • 问题出在 Apache commons lib 中的解析。

标签: java ftp ftp-client filezilla ftp-server


【解决方案1】:

当 FTP 服务器针对 SYST 命令返回 null 时,apache-commons 1.4.1 在处理解​​析异常时存在严重问题。我尝试使用 3.2 版,问题得到解决。

【讨论】:

    猜你喜欢
    • 2016-01-21
    • 1970-01-01
    • 2015-07-13
    • 2014-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-23
    相关资源
    最近更新 更多