現象:java
在springboot的定時器輪詢去下載ftp文件時,報如下錯誤:spring
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)apache
緣由分析:springboot
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網絡
證明了就是鏈接數滿形成。session
解決方案:this
將FTPClient.connect();
改爲:
if(!FTPClient.isConnected()){
FTPClient.connect();
}.net
故此解決。但願能幫到你們。get