FTP连接超时421:解析器错误 [英] FTP Connection Timed out 421 : parser error

查看:1880
本文介绍了FTP连接超时421:解析器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑问题。我试图列出FTP目录中的所有文件 - 虽然代码在正常的Netbeans项目中运行时工作正常,但当在Maven项目中使用相同的代码时,其连接中的结果超时421 。我怎样才能摆脱这一点?
$ b 代码:

  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(); //它可以工作
ftpClient.listNames(/); //它工作
ftpClient.changeWorkingDirectory(/); //它可以工作
FTPFile [] files = ftpClient.listFiles(/); //它挂起并停止421连接超时

FileZilla日志为: -

 (000370 )04-04-2013 16:04:32  - (未登录)(127.0.0.1)>已连接,发送欢迎信息... 
(000370)04-04-2013 16:04:32 - (未登录)(127.0.0.1)> 220 ftp连接开始...
(000370)04-04-2013 16:04:32 - (未登录)(127.0.0.1)> USER raja
(000370)04-04-2013 16:04:32 - (未登录)(127.0.0.1)> 331 raja
所需的密码(000370)04-04-2013 16:04:32 - (未登录)(127.0.0.1)> PASS ****
(000370)04-04-2013 16:04:32 - raja(127.0.0.1)> 230登录
(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类型设置为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进入被动模式(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由FileZilla模拟的UNIX
(000366)04-04-2013 16:04:33 - raja(127.0.0.1)> 421连接超时。

客户端例外情况如下: -

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

The question has beed edited. I am trying to list all the files in a FTP directory - and though the code works fine when run in a normal Netbeans project, when using the same code in a Maven project its results in a connection timed out 421 . How can I get rid of this?

Code:

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

The FileZilla log is:-

    (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.

The Client side exceptions are:-

解决方案

There is a serious issue in the apache-commons 1.4.1 in handling the parsing exception when the FTP server returns null against SYST command . I tried using version 3.2 and the issue got resolved.

这篇关于FTP连接超时421:解析器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆