There is an FTP connection method

public boolean ftpConnect(String host, String username, String password, int port) { boolean status = false; Log.d("myLog", "host " + host + " username " + username + " password " + password + " port "+ port); try { mFTPClient = new FTPClient(); mFTPClient.connect(host, port); Log.d("myLog", "Код ответа" + mFTPClient.getReplyCode()); if (FTPReply.isPositiveCompletion(mFTPClient.getReplyCode())) { status = mFTPClient.login(username, password); mFTPClient.setFileType(FTP.BINARY_FILE_TYPE); mFTPClient.enterLocalPassiveMode(); } Log.d("myLog", "Все прошло успешно"); } catch (Exception e) { Log.d("myLog", "Error: could not connect to host " + host + " " + e); } return status; } 

I try to connect, but it does not appear, why without a clue, I thought that I’m entering the login and password data incorrectly, made a debug output and everything is correct. everything works fine in FTP clients.

  • And what is displayed in the log? - KoVadim
  • 07-22 23: 05: 37.877 14015-14015 / ru.landmarkstst.educt D / myLog: host ***** username **** password ***** port 21 07-22 23: 05: 37.892 14015- 14015 / ru.landmarkstd.educt D / myLog: Error: could not connect to host 78.108.80.117 android.os.NetworkOnMainThreadException 07-22 23: 05: 37.892 Andrew
  • here's your problem - "android.os.NetworkOnMainThreadException". - it is impossible to make network requests in the main stream. - KoVadim
  • To take out everything in asynctask? - Andrey
  • or a separate thread. - There are many articles on the Internet on this topic. - KoVadim

0