Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.8k views
in Java FTP by (160 points)
Dear all,

I am getting the following exception:

com.enterprisedt.net.ftp.FTPException: Possible PASV port theft, cannot open data connection.
   at com.enterprisedt.net.ftp.FTPControlSocket.validateReply(FTPControlSocket.java:702)
   at com.enterprisedt.net.ftp.FTPClient.dir(FTPClient.java:2273)
   at com.enterprisedt.net.ftp.FTPClient.dirDetails(FTPClient.java:2210)
   at com.sisl.snms.saf.parser.ftpschdlr.FtpNotificationListener.handleNotification(Unknown Source)
   at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor$ListenerWrapper.handleNotification(DefaultMBeanServerInterceptor.java:1652)
   at javax.management.NotificationBroadcasterSupport.handleNotification(NotificationBroadcasterSupport.java:221)
   at javax.management.NotificationBroadcasterSupport.sendNotification(NotificationBroadcasterSupport.java:184)
   at javax.management.timer.Timer.sendNotification(Timer.java:1295)
   at javax.management.timer.Timer.notifyAlarmClock(Timer.java:1264)
   at javax.management.timer.TimerAlarmClock.run(Timer.java:1347)
   at java.util.TimerThread.mainLoop(Timer.java:512)
   at java.util.TimerThread.run(Timer.java:462)


I am also attaching the code:

FTPClient enterpriseFtp = null;
enterpriseFtp = new FTPClient();
enterpriseFtp.setRemoteHost(host);
FTPMessageCollector listener = new FTPMessageCollector();
enterpriseFtp.setMessageListener(listener);
// connect
enterpriseFtp.connect();
// login
enterpriseFtp.login(user, password);
enterpriseFtp.setType(FTPTransferType.ASCII);

// change to remote directory and print it to console

if((remote_dir != null) && !(remote_dir.trim().equalsIgnoreCase(""))){
     enterpriseFtp.chdir(remote_dir);
   }

//Now change to the system-specific(i.e. capri/samson) directory
enterpriseFtp.chdir(system);
remoteFiles = enterpriseFtp.dirDetails(enterpriseFtp.pwd());

enterpriseFtp.get(localDir + sep + system + sep +
            remoteFiles[i].getName(),
            remoteFiles[i].getName());
enterpriseFtp.quit();

2 Answers

0 votes
by (51.6k points)
The server is probably telling you that the address of the client that connected to the data channel that it opened for the file transfer is not the one that it expected. A search on Google for "Possible PASV port theft, cannot open data connection" got quite a few hits. They tend to suggest reconfiguring the server. For example, on the macromedia website they say:
This error is common and occurs due to restrictions on the FTP server. To prevent this error, consult the FTP server configuration instructions or consult with the Server Administrator or ISP. Configuration will differ depending on the FTP server software used:
  • If you are using the ProFTPD FTP server, add the "AllowForeignAddress on" directive to the Virtual Address section of the configuration file.
  • If you are using the WU-FTPD FTP server, add the following lines to the configuration file:
          pasv-allow all + valid IP address
          port-allow all + valid IP address
    
  • If you are using another FTP server, please consult configuration documentation or speak to your Server Administrator or ISP.


It could also be a firewall-related issue. Are you on the same server as the LAN or are there firewalls involved on either or both ends?

- Hans (EDT)
0 votes
by (160 points)
Thanks for the reply.
The same FTP server works well with CoreFTP Client. The client log are as follows:
elcome to Core FTP, release ver 1.3c, build 1417.02 (U) -- 

Categories

...