Hi,
we encountered an issue with uploading files to the server using class
org.apache.commons.net.ftp.FTPSClient:

Caused by: org.apache.commons.net.ftp.FTPConnectionClosedException:
Connection closed without indication.
at org.apache.commons.net.ftp.FTP.getReply(FTP.java:593)
at org.apache.commons.net.ftp.FTP.getReply(FTP.java:581)
at
org.apache.commons.net.ftp.FTPClient.completePendingCommand(FTPClient.java:1187)
at
org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:1995)
at
org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2082)
at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2282)
at
works.buddy.ws.transfer.services.FtpTransferClient.dirDetails(FtpTransferClient.java:289)

It's interesting because when we use FTPClient then it works.

To recreate you can set up a server yourself:

docker run -p 21:21 -p 30000-30009:30000-30009 \
-e FTP_USER_NAME=bob \
-e FTP_USER_PASS=password \
-e FTP_USER_HOME=/home/bob \
-e FTP_PASSIVE_PORTS=30000:30009 \
-e "PUBLICHOST=<YOUR-IP-HERE>" \
-e "ADDED_FLAGS=--tls=1" \
-e "TLS_CN=example.com" \
-e "TLS_ORG=BDY" \
-e "TLS_C=PL" \
-v /ftp:/home/bob \
--name pure-ftpd \
stilliard/pure-ftpd

Example code:

FTPSClient client = new FTPSClient();
client.setAuthValue("TLS");
client.setControlEncoding("UTF-8");
client.connect("<YOUR-IP-HERE>", 21);
client.login("bob", "passw");
client.setKeepAlive(true);
client.enterLocalPassiveMode();
client.execPBSZ(0);
client.execPROT("P");
client.setFileType(FTP.BINARY_FILE_TYPE);

client.storeFile(remotePath, inputStream)

Best regards,
Tomo

Reply via email to