Ad

Getting "Unable To Determine System Type - Response: 500 Unknow Command" When Listing Files On ESP8266 With Apache Commons Net

- 1 answer

I try to connect to FTP server in ESP8266. Connection is successful, but I can't get list of files on the server.

My code is:

FTPClient mFtpClient = new FTPClient();
mFtpClient.setConnectTimeout(10000);
mFtpClient.connect(InetAddress.getByName(ip));
status = mFtpClient.login(userName, pass);
Log.e("isFTPConnected", String.valueOf(status));
if (FTPReply.isPositiveCompletion(mFtpClient.getReplyCode())) {
    mFtpClient.setFileType(FTP.BINARY_FILE_TYPE);
    mFtpClient.enterLocalPassiveMode();
    FTPFile[] mFileArray = mFtpClient.listFiles();
    Log.e("Size", String.valueOf(mFileArray.length));
}

In logical I get the error :

java.io.IOException: Unable to determine system type - response: 500 Unknow command.

I use Apache Commons Net FTP library. So what is wrong in my code? From FileZilla Windows client, I can connect. May be the reason is that in ESP is SPIFF file system? Or another one reason?

Thanks for answers, and interest!

Ad

Answer

Your server does not support SYST command, that the FTPClient needs to decide how to parse a response of LIST command.

Solutions are:

  • If your server supports MLSD command, use mlistDir instead of listFiles.
  • Or use System.setProperty to set FTP_SYSTEM_TYPE_DEFAULT or FTP_SYSTEM_TYPE to suggest what directory listing format your server is using.
Ad
source: stackoverflow.com
Ad