commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ricardo Duval <rdg.du...@ibest.com.br>
Subject Commons-net EPRT and Microsoft FTP Server
Date Mon, 24 May 2010 23:25:20 GMT
Gentlemen,

One more question about commons-net and erratic FTP servers.

I've been tried to download some files from a Microsoft FTP Service server
and I noticed org.apache.commons.net.ftp.FTPClient always send an EPRT
command before any file retrieval. I think its causing some issues on my app
client, since I got the following error after sending EPRT:

java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:168)
    at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
    ...
    at
tests.integrated.service.FtpClientMsTest.testMsConnection(FtpClientMsTest.java:90)


The Command Listener I added to the client shows the following command
lines:

220 Microsoft FTP Service
USER SOME_USER
331 Password required for SOME_USER
PASS SOME_PASSWD
230 User SOME_USER logged in.
SYST
215 Windows_NT
EPRT |1|LOCAL_MACHINE_IP|0|

After the EPRT command, all freezes up for a while and then I got the above
exception. I tried to set the EPSV command, but the server doesn't recognize
it.

This is the test which causes the error, and notice the command execution
never reaches the "client.retrieveFileStream()" line (well, technically it
does, but never executes the RETR or anything beyond the EPRT):

    @Test
    public final void testMsConnection() throws Exception {
        FTPClient client = new FTPClient();
        client.addProtocolCommandListener(new PrintCommandListener(
                new PrintWriter(System.out)));
        client.connect("SOME_FTP_SERVER");
        assertTrue(client.login("SOME_USER", "SOME_PASSWD"));
        InputStream is = client.retrieveFileStream("REMOTE_FILE.xml.zip");
// Line 90
        File local = new File(someLocalFolder, "AAA.zip");
        FileUtils.writeByteArrayToFile(local, IOUtils.toByteArray(is));
        is.close();
        assertTrue(client.logout());
        client.disconnect();
    }

Is there any way (configuration) to avoid sending EPRT command before all
list or file retrieval methods?

Thanks in advance,
--
R. Duval

PS: Using the low level org.apache.commons.net.ftp.FTP class I was able to
retrieve the file using RETR.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message