commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike" <mike.errec...@laposte.net>
Subject [Net] FTP problem
Date Tue, 01 Jul 2003 07:32:04 GMT
(English is not my native language)

Hello all.

This is my first message on the list. I read the archives but did'nt find any answers, so...
I try here.

I'm trying to use Commons-Net for FTP (GET and PUT). The API looks quite simple (i mean clear
and understandable), but i have a problem right after the connection, using the FTPClient
class :

java.io.IOException: Host attempting data connection 192.168.1.229 is not same as server 213.XXX.XXX.XXX
(i replaced the real IP with some XXX)
 at org.apache.commons.net.ftp.FTPClient.__openDataConnection(FTPClient.java:409)
 at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:1930)
 at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:1964)
 at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2020)
 at TestCommonsNet.main(TestCommonsNet.java:40).


192.168.1.229 and 213.XXX.XXX.XXX  are the same machine, 192.XXX is the local IP, and 213.XXX
the public one. 

The problem occurs on the ftp.listFiles() method call.

I'm working on a machine without an external IP, which uses a gateway (the 213.XXX machine)
to access the web.

Anyone knows how to solve this problem ?

Thanks in advance !

Mike




Here is the source code :

try {
   FTPClient ftp = new FTPClient();
   ftp.connect(SERVER);
   ftp.login(USER, PASS);
   System.out.println("Connected to " + SERVER + ".");
   System.out.print(ftp.getReplyString());

   // List the files in the directory
   ftp.changeWorkingDirectory(SRCFOLDER);
   
   FTPFile[] files = ftp.listFiles();
   
   File file =
     new File(
      DESTINATIONFOLDER
       + File.separator
       + files[i].getName());
    FileOutputStream fos = new FileOutputStream(file);

    ftp.retrieveFile(files[i].getName(), fos);
 
    fos.close();
  
   // Logout from the FTP Server and disconnect
   ftp.logout();
   ftp.disconnect();

  } catch (Exception e) {
   e.printStackTrace();
  }

 }

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