FTP response 421 received. Server closed connection
现象:
在springboot的定时器轮询去下载ftp文件时,报以下错误:
org.apache.commons.net.ftp.FTPConnectionClosedException: FTP response 421 received. Server closed connection.
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:367)
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:294)
at org.apache.commons.net.ftp.FTP._connectAction_(FTP.java:400)
at org.apache.commons.net.ftp.FTPClient._connectAction_(FTPClient.java:924)
原因分析:
1.Connection closed without indication.//FTP服务器服务有故障,或是是网络问题。
2. FTP response 421 received. Server closed connection.//错误原因就是FTP服务器端连接数满了
故得知是因为原因2造成ftp的连接数满了,又查看vsftp.log得到:too many sessions for this address
证实了就是连接数满造成。
解决方案:
将FTPClient.connect();
改成:
if(!FTPClient.isConnected()){
FTPClient.connect();
}
故此解决。希望能帮到大家。