Steve,
I followed your sugestion on both tests, the one I try to list and the one
intended to upload a file but both showed different behaviors.
When I run this test:
@Test
public void testPerformanceFtpRiscf80Interno() throws Exception {
FTPClient client = new FTPClient();
try {
client.connect(SOME_AIX_HOST);
System.out.println(client.getReplyString());
if(client.login(SOME_USER, SOME_PASS)) {
System.out.println(client.getReplyString());
client.pwd();
System.out.println(client.getReplyString());
client.enterLocalPassiveMode();
System.out.println(client.getReplyString());
client.list(); // <-- Still generates the 425 reply code
System.out.println(client.getReplyString());
}
} finally {
client.logout();
client.disconnect();
}
}
I still get the same MalformedServerReplyException (Server Reply: : A remote
host refused an attempted connect operation.) on client.logout() method and
got the following server replies:
220 riscf80 FTP server (Version 4.2 Fri May 2 12:48:10 CDT 2008) ready.
230-Last unsuccessful login: Fri Apr 23 18:06:21 GRNLNDST 2010 on /dev/pts/4
from SOME_HOME
230-Last login: Fri Apr 23 18:42:58 GRNLNDST 2010 on ftp from SOME_HOME
230 User SOME_USER logged in.
257 "/riscf80/some/path" is current directory.
425 No data connection
But when I changed the test method intended to upload a file I got very
different results, the test succeeded and the file was transferred to the
host like the code extract below shows. It's interesting to notice I removed
the preferIPv4Stack property.
...
fis = new FileInputStream(file);
ftp.enterLocalPassiveMode();
ftp.storeFile(fileName, fis);
...
Printing some output I got the following results:
IPv4: null
220 riscf80 FTP server (Version 4.2 Fri May 2 12:48:10 CDT 2008) ready.
230-Last unsuccessful login: Fri Apr 23 18:06:21 GRNLNDST 2010 on /dev/pts/4
from SOME_HOME
230-Last login: Fri Apr 23 18:52:39 GRNLNDST 2010 on ftp from SOME_HOME
230 User SOME_USER logged in.
250 CWD command successful.
226 Transfer complete.
221 Goodbye.
I also tried the FTPClient#listNames high level method and that worked fine
using local passive mode.
Thanks
2010/4/23 Steve Cole <[email protected]>
> You said you already tried changing active/passive mode. Did you set after
> login, just before the list() method?
>
> if (passiveMode){
> ftpClient.enterLocalPassiveMode();
> }else{
> ftpClient.enterLocalActiveMode();
> }
> ftpClient.list();
>
>
> -----Original Message-----
> From: Ricardo Duval [mailto:[email protected]]
> Sent: Friday, April 23, 2010 3:32 PM
> To: Commons Users List
> Subject: Re: Commons-net FTP and AIX 5.3 FTP Server
>
> Steve,
>
> I had already tried setting this parameter manually (on System class). Just
> to be sure, now follow the results passing it on command line execution
> (Maven test):
>
> C:\devel\workspace-nfe\ftp-proof>mvn -Dtest=FtpCommonsNetTest
> -Djava.net.preferIPv4Stack=true test
> ...
> Results :
> Tests in error:
> testRiscf80(testes.integracao.FtpCommonsNetTest)
> Tests run: 3, Failures: 0, Errors: 1, Skipped: 2
> ...
>
> And these are the individual test results:
>
> Tests run: 3, Failures: 0, Errors: 1, Skipped: 2, Time elapsed: 0.25 sec
> <<<
> FAILURE!
> testRiscf80(tests.integrated.FtpCommonsNetTest) Time elapsed: 0.156 sec
> <<< ERROR!
> org.apache.commons.net.MalformedServerReplyException: Could not parse
> response code.
> Server Reply: : The socket name is not available on this system.
> at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:316)
> at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:491)
> at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:533)
> at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:582)
> at org.apache.commons.net.ftp.FTP.quit(FTP.java:790)
> at org.apache.commons.net.ftp.FTPClient.logout(FTPClient.java:759)
> ...
>
> Based on this test:
>
> @Test
> public final void testRiscf80() throws Exception {
> FTPClient ftp = new FTPClient();
> FileInputStream fis = null;
> try {
> ftp.connect(SOME_AIX_HOST);
> ftp.login(SOME_USER, SOME_PASS);
> ftp.changeWorkingDirectory("/riscf80/some/remote/path");
> File file = new File(PATH, FILE_NAME);
> fis = new FileInputStream(file);
> ftp.storeFile(fileName, fis);
> } finally {
> ftp.logout();
> ftp.disconnect();
> if(fis != null) { fis.close(); }
> }
> }
>
> I double checked to see if the preferIPv4Stack was there on the execution
> properties, and I also tried passing java.net.preferIPv6Stack=false, but
> for
> no avail.
>
> Thanks
>
> 2010/4/23 Steve Cole <[email protected]>
>
> > The exception is occurring when a QUIT command is sent, simply because it
> > failed to parse the server reply. The actual problem appears to be a
> > connection issue. It can't open the data connection. That's why list()
> > failed. Have you tried setting the property
> java.net.preferIPv4Stack=true?
>