0

I am getting following error after trying to download file from FTP using ftp4j in android.

W/System.err: it.sauronsoftware.ftp4j.FTPException [code=426, message= Data connection error.]
12-16 11:29:30.496 22976-23595/  W/System.err:     at it.sauronsoftware.ftp4j.FTPClient.download(FTPClient.java:3484)
12-16 11:29:30.496 22976-23595/  W/System.err:     at it.sauronsoftware.ftp4j.FTPClient.download(FTPClient.java:3276)
12-16 11:29:30.496 22976-23595/  W/System.err:     at it.sauronsoftware.ftp4j.FTPClient.download(FTPClient.java:3181)
12-16 11:29:30.496 22976-23595/  W/System.err:     at  .MainActivity$FTPDownload.doInBackground(MainActivity.java:248)
12-16 11:29:30.496 22976-23595/  W/System.err:     at  .MainActivity$FTPDownload.doInBackground(MainActivity.java:234)
12-16 11:29:30.496 22976-23595/  W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:292)
12-16 11:29:30.496 22976-23595/  W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
12-16 11:29:30.496 22976-23595/  W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
12-16 11:29:30.496 22976-23595/  W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
12-16 11:29:30.496 22976-23595/  W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
12-16 11:29:30.496 22976-23595/  W/System.err:     at java.lang.Thread.run(Thread.java:818)

Following code I am using for download from ftp :

                FTPClient client = new FTPClient();
                client.setAutoNoopTimeout( 30000);
                client.connect(FTP_HOST_DOWNLOAD,FTP_DOWNLOAD_PORT);
                client.setPassive(true);
                client.login(FTP_DOWNLOAD_USER, FTP_PASS_DOWNLOAD);
                client.setType(it.sauronsoftware.ftp4j.FTPClient.TYPE_BINARY);
                Log.d("Dir current",""+client.currentDirectory());

                client.changeDirectory("/Private/testftp");
                Log.d("Dir current",""+client.currentDirectory());
                File file_local = new File(Environment.getExternalStorageDirectory() + File.separator + LOCAL_FILE_DOWNLOAD);
                client.download(FILE_DOWNLOAD, file_local, new MyTransferListener());

Error code 426 is for host connectivity but connection to FTP is happening.

Mr. Sajid Shaikh
  • 7,051
  • 4
  • 21
  • 35
  • The FTP 426 response code indicates that the FTP client connected to the FTP server on a control connection, then opened a data connection (a separate TCP connection) for a data transfer (_e.g._ downloading a file); the FTP server received the download request, but _aborted_ that transfer for some reason. You may have to check the FTP server logs to see why it would abort your data transfer. – Castaglia Dec 21 '16 at 16:12
  • did you get solution for this? I am also looking for solution. – piyush poriya Mar 30 '17 at 05:27
  • as mentioned by @Castaglia above problem because of server aborted that transfer for some reason. Now its working fine with same code – Mr. Sajid Shaikh Nov 21 '17 at 09:58

0 Answers0