Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FTP response 421 received. Server closed connection

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:

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:

setDefaultTimeout(6000); 
setConnectTimeout(3000);
setSoTimeout(3000);
enterLocalPassiveMode();

and sending NOOP, but still getting the same error.

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.

Please help and ask if any other information is required. I am new to JAVA.

like image 782
crazyproton Avatar asked Jul 17 '14 09:07

crazyproton


People also ask

What does 421 service not available mean?

FTP error 421 service not available – A Quick Glance And, FTP error 421 service not available means that the connection to the remote server can't be established. FTP clients such as Filezilla returns the error like this: 421 Service not available, remote server has closed connection.

Why is FTP not connecting?

Your firewall could be blocking it. Ensure you have the IP address in your welcome email for hostname (only the numbers; don't add FTP, www, or anything else). Make sure your username and password are the same as your control panel username and password. Some FTP programs require a path to connect.


1 Answers

See here: 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.

like image 170
fiffy Avatar answered Sep 24 '22 21:09

fiffy