Problems With, Getting FTP Response 421 Received Error

- 1 answer

I have some Issue using Here is my code:

if (!FTPReply.isPositiveCompletion(reply)) {
    logger.debug("Fehler beim FTP verbindungsaufbau " + reply);
FileInputStream fis = new FileInputStream(ziel);"....uploading...");
ftpClient.storeFile(cntKen + dateiEndung, fis);

The connection to the FTP-Server is ok, but when I try to upload a file to this FTP-Server I receive a FTP response 421 received error message. With the ftpClient.storeFile(cntKen + dateiEndung, fis) line.

The same code is working with others FTP-Servers, so I am not sure, it is a problem with the code or with some configuration of the ftp server itself.

Any ideas?

Edit: While i read for more informations. The error seams to occour when the server allows only 1 connection at the same time. Maybe the lib make more than 1 connection?



The Solution is pretty simple. The error means, the ftp server disconneted you since the connect for some reason. So the connection to the ftp server worked, but until the upload of the file, the connection was lost. In this case here, because between the connection and the upload was a ilde time of 5 minutes. The FTP Server was configured to disconnect idle connections after 2 minutes. The disconnection could have some other reasons if you occour the same problem. But in fact the ftp connection was lost, and using .storeFile (or the ftp) is not responding no connection, but a 421 error code

Two ways for solution: 1. prevered: Optimize the software. Check if the ftp connections works, then close the connection. Open it again just in front of the upload. 2. Change FTP-Settings to disconnect idle connections to a higher value