Java 收到 FTP 响应 421。服务器关闭连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24799518/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
FTP response 421 received. Server closed connection
提问by crazyproton
I am writing a JAVA code to traverse FTP Location using Apache Commons Net FTPClient and getting output in an Excel file. the code execute correctly for approx 5 min but then gives an IOException:
我正在编写 JAVA 代码以使用 Apache Commons Net FTPClient 遍历 FTP 位置并在 Excel 文件中获取输出。代码正确执行了大约 5 分钟,但随后给出了 IOException:
org.apache.commons.net.ftp.FTPConnectionClosedException: FTP response 421 received. Server closed connection.
I am using commons-net-3.0.1.jar. I have done some R&D and tried:
我正在使用 commons-net-3.0.1.jar。我做了一些研发并尝试过:
setDefaultTimeout(6000);
setConnectTimeout(3000);
setSoTimeout(3000);
enterLocalPassiveMode();
and sending NOOP
, but still getting the same error.
并发送NOOP
,但仍然出现相同的错误。
All I am trying to do is traverse through a directory and if file is found than get file name and file update date in excel else if directory is found then get inside and do until file is found again.
我想要做的就是遍历一个目录,如果找到文件,则在 excel 中获取文件名和文件更新日期,否则如果找到目录,则进入并执行直到再次找到文件。
Please help and ask if any other information is required. I am new to JAVA.
请帮助并询问是否需要任何其他信息。我是 JAVA 新手。
采纳答案by fiffy
See here: http://kb.globalscape.com/KnowledgebaseArticle10142.aspx
见这里:http: //kb.globalscape.com/KnowledgebaseArticle10142.aspx
Error 421 Service not available, closing control connection. Error 421 User limit reached Error 421 You are not authorized to make the connection Error 421 Max connections reached Error 421 Max connections exceeded
Maybe you're not reusing a connection but using a new connection for every request, flooding the server with connections until it hits the connection limit. Try closing your connections or resuing them.
也许您没有重用连接,而是为每个请求使用新连接,用连接淹没服务器,直到达到连接限制。尝试关闭您的连接或恢复它们。
回答by Mohd Abdul Mujib
For future reference..
备查..
If the solution by @fiffy didn't work, maybe try turning on the TLS (FTPS/Secure Connection), My server was set to only accept FTPS protocol, so it was rejecting my unencrypted connection, so turning on the TLS (FTPS) helped me solve the prob.
如果@fiffy 的解决方案不起作用,也许尝试打开 TLS(FTPS/安全连接),我的服务器被设置为只接受 FTPS 协议,所以它拒绝了我的未加密连接,所以打开 TLS(FTPS)帮我解决了问题。
Note:- This error FTP response 421 received
is very prominent in Netbeanssince its also built in java.
注意:- 这个错误FTP response 421 received
在Netbeans 中非常突出,因为它也是内置于 java 中的。