Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
13.5k views
in Java FTP by (400 points)
Hi together,

I am new to the forum and need help from the ftp experts from enterprisedt.com.

General:
I am about to finalize the development for an android app, where I used the java ftp library from enterprisedt.com. When the app is finished and working, I will buy the edtFTPj/PRO license for 499 dollar when I release it.
One part of the app is to upload and download a file via ftp and measure the upload and download data rate.

Problem:
The integration worked fine and in general everything works.
BUT whereas the upload speed is in the same range as I can see with reference tests (e.g. via windows laptop and command line ftp tool), the download speed is significant lower.

Example:
UL DL
~1000 KB/s ~600 KB/s (my Android App with Samsung Galaxy S2)
~1000 KB/s ~3000 KB/s (reference tests)

What I tried:
- play arround with buffer size
- do not register an event listener at the ftp library
- do not store the received data to disc (because I thought maybe writing into a file may be the botte neck under android)
- take only the ftp code out of my complex app and build an absolut easy app with only one button to start the download

but all that does not change anything!

What I tried next:
- build an simple java application with exactly the same ftp code used in the easy android app and run it from my window pc
=> the same code reaches the expected download rate!!!
- downloaded a free ftp android app ('AndFTP') from play store and downloaded exactly the same file
=> also this android app reaches the expected download rate!!!

So now I am completely gone! Everything I tried to nail down the problem does not help, and with the fact, that the same code works on a different OS and other ftp apps like 'AndFTP' works well on my android phone, everything makes not sense.

Has anyone an idea, what in general can prevent a ftp download to reach the expected throughput?

Has anyone made same experience using the library under android OS? E.g. maybe the use of threads is somehow not compatible? But why the upload is working fine?

Thanks for any help.

15 Answers

0 votes
by (162k points)
Is this "plain" unencrypted FTP?

Could you post a bit of your code that you use for the download?
0 votes
by (400 points)
Sorry for my delay. I thought I will get an email when my thread receives a reply. By random I looked at here again.

Yes, it is not encrypted.

The code is nothing more than this:

   FileTransferClient ftpClient =  new FileTransferClient();

   try {
         ftpClient.setRemoteHost( "..." );
         ftpClient.setUserName(   "..." );
         ftpClient.setPassword(   "..." );
         
         //ftpClient.setEventListener( this );
         
         ftpClient.connect();
         
         ftpClient.downloadFile( "/data/data/de.test/ernahugo", "./speedtest/download/acttftp_10000K.bin" );
         
         ftpClient.disconnect();
                  
         
   } catch (FTPException e) {
         System.out.println("FTPException: "+e.toString());
   } catch (IOException e) {
         System.out.println("IOException: "+e.toString());
   } catch (Exception e) {
         System.out.println("Exception: "+e.toString());
   }



In my first post I forgot to say that I test over my local Wifi from PC, laptop or smartphone.
0 votes
by (162k points)
It sounds specific to Android and Java. Have you tried another Android Java FTP library to compare speeds?

edtFTPj/PRO is normally as fast as other clients as you've seen on the PC.
0 votes
by (400 points)
This would be my next approach. Looking for an other library to see what happens.

Bytheway, I tested with two other android devices. All do not reach the full available download speed, but are different from my samsung galaxy s2:

Download of a 10 MB file with the same simple app:

Samsungs Galaxy SII:               ~ 17 Seconds
HTC Desire:                        ~  7 Seconds
Huawai MediaTab:                   ~  7 Seconds
---
Reference (Windows Laptop):        ~  3 Seconds
Reference (AndFTP app with SGSII): ~  3 Seconds


Its strange why the fastest android device is the slowest.

One Question:
Do someone of you know how many threads the edtFTPj java library usually opens in background when downloading a file?
0 votes
by (400 points)
So now I tried two different libraries. Both show much faster download.

With the library called 'FTP4j' I now have following results integrated in my easy app and the 10 MB download file:

Samsungs Galaxy SII:               ~  3 Seconds
HTC Desire:                        ~  6 Seconds
Huawai MediaTab:                   ~  3 Seconds 


This is interesting. The SGSII downloads now in 3 seconds where it was arround 17 seconds before. Don't know what can be the difference in implementation of the download between this and the edtFTPj library? It is ok, that the HTC Desire does not reach the maximum, because it has the slowest cpu.

So one can say, that I found a proper ftp library. But it is not easy to switch to a new ftp library, because
- the licensing is not so clear with the above one
- the overall behavior e.g. in case of errors or temporarily interrupts (=robustness) is not known
- the possible monitoring needs to checked

I would rather like to see if the developers of the edtFTPj can do some investigation which code parts could for example cause a delay etc. First theoretically, later if possible directly under android.
My experience is telling me, that if the root cause is found, it is a small item that needs to be changed to run as fast as other ftp libraries under android.

So I would like to stick at edtFTPj, let see ...
0 votes
by (162k points)
I suspect the difference is the TCP buffer size. You can set it in FTPClient, but not in FileTransferClient.

If you email us I'll send you the latest (unreleased) version that allows you to change it.
0 votes
by (400 points)
That would be really great. To whom shall I email exactly? Or can you send it just to the email assigned to my account here?
0 votes
by (162k points)
Send a request to support at enterprisedt dot com.
0 votes
by (400 points)
Ok, I will contact there soon.

Since I have also the java source code of the library I could directly manipulate the value in FTPClient.java:

protected int dataReceiveBufferSize =0;

Am I right?

What values for that TCP buffer size are you thinking I shall play arround with? Will try that after work, when I am at home.
0 votes
by (162k points)
Yes, try dataReceiveBufferSize = dataSendBufferSize = 128*1024 to start with, and then try 512*1024

Categories

...