0

I'm using apache.commons.net ftpClient but I'm facing a problem that I'm not sure how to fix.

So basically I log in the server, set the passive mode, and then I run:

fileFTPFiles = this.ftpClient.listFiles(strPath);

In all the servers I have connected to until today, this worked like a charm but today I connected to a server that instead of returning the file or the files in the give path always returns the landing directory files...

Although if I run

fileFTPFiles = this.ftpClient.mlistDir(strPath);

it returns what I expect.

Can anyone explain me why this happens and if there is a easy way to detect whether to use listFile or mlistFiles?

sushain97
  • 2,752
  • 1
  • 25
  • 36
Killercode
  • 894
  • 1
  • 20
  • 34

1 Answers1

0

Did you set the local passive mode or remote? I had the same problem and I found some explanations on the FileZilla Documentation: https://wiki.filezilla-project.org/Network_Configuration.

This happened to me because my ftp client was not able to bound the server's port returned by PORT ftp command(sent before every request). By the way, the FTPCLient.setActivePortRange(min, max); method don't take effect at all;

The easiest way to avoid this seems to create a raw socket to verify network bindness at the address.

bleidi
  • 100
  • 8