You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Thomas Prus <th...@buddy.works.INVALID> on 2024/11/21 12:48:07 UTC

Connection closed without indication

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

Re: Connection closed without indication

Posted by Thomas Prus <th...@buddy.works.INVALID>.
Sorry, corrected version here
https://lists.apache.org/thread/xbh62dpb17opv11g1f87dv9ghcmwvhct

On Thu, Nov 21, 2024 at 1:48 PM Thomas Prus <th...@buddy.works> wrote:

> 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
>