Android Question Slow file upload with HTTPServer

William Hunter

Active Member
Licensed User
Longtime User
I have been doing a rewrite of an app I did a few years ago that uses HTTPServer. I have noticed that file transfer upload speeds to an Android device is very slow. I recalled that I had found the upload speed a few years ago to be acceptable.

This prompted me to do some testing on four different devices. These are the results:

HTTPServer speed test. - 1,080 KB file uploaded to Android device.

1. ViewSonic ViewPad – 512 MB RAM - SDK8

24 seconds

2. Samsung Note 10.1 – 2 GB RAM - SDK16

76 seconds

3. HP Slate 7 - 1 GB RAM - SDK17

76 seconds

4. Motorola Moto G - 1 GB RAM - SDK23

25 seconds

Device number one does not have AntiVirus protection, while the three other devices are protected by Avast. I thought the AntiVirus might be slowing things down. So, I uninstalled it from the Samsung Note 10.1. This made no difference in upload speed.

I then thought it might be Google Play protect that was slowing things down. I turned it off on the Samsung Note 10.1. This again made no difference in upload speed.

I found Erel’s explanation that it was likely base64 decoding, that was slowing things down, at the link below:

https://www.b4x.com/android/forum/threads/httpserver-upload-very-slow.57143/

With the variation in upload speed with these devices, it has me wondering if it is something other than base64 decoding that is the problem. Would there be anything in HTTPServer itself that could be improved? I like the ability to make Wifi file transfers, using the client’s browser alone, with no other software in the mix on that side. If only the upload speed could be improved. I would think in this case it should be no more than a few seconds or so. Anyone have any thoughts?
 

William Hunter

Active Member
Licensed User
Longtime User
Building the request requites quite a lot of work on the client side as it needs to base64 encode the file and build a very large multipart request. This is really not an efficient solution.
Thank you Erel. I like the ability to transfer files by WIFI, using only a browser on the client side. It is so simple and convenient. If only the upload speed to the Android device wasn’t so slow.

I found an app at Google play that is very fast in file transfer speed. This app does not seem to be hampered by base64 encoding on the client side. The author has somehow overcome this limitation. There is a free version as well as a paid version. I have been using the paid version.

These are the Google Play links, if you care to take a look:

1. WiFi File Transfer (free version)

https://play.google.com/store/apps/details?id=com.smarterdroid.wififiletransfer&hl=en

2. WiFi File Transfer Pro (paid version)

https://play.google.com/store/apps/details?id=com.smarterdroid.wififiletransferpro&hl=en

Would there be some way, other than using HTTPServer, to create a Wifi file transfer app in B4A that would require only a browser on the client side? Any other means I can think of requires the installation of other software on the client side.

Best regards :)
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
i believe from browser to any pc with public domain/ip : port you need web sockets protocol.
 
Last edited:
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
Yes, but building a WebSocket server in B4A is not simple. And maybe not that useful...
i not spoke about b4a, more b4j or c# because he spoke about "require only a browser on the client side"
the fastes way is a b4a android app via tcp socket and binary transport to any selfmade server app or the same b4a app.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
I have noticed that file transfer upload speeds to an Android device is very slow
So the server is on an Android device? How about the clients? Are they all Android? The reason I'm asking is that this stackoverflow question (well, some of the answers, see https://stackoverflow.com/questions/35323838/java-file-uploading-painfully-slow) seems to hint that the HTTP library from Android my be the culprit. Therefore, it may be your client devices that are slow, not the server. Easy way to test - use a non-android device to upload a file.
 
Upvote 0

William Hunter

Active Member
Licensed User
Longtime User
So the server is on an Android device? How about the clients? Are they all Android? The reason I'm asking is that this stackoverflow question (well, some of the answers, see https://stackoverflow.com/questions/35323838/java-file-uploading-painfully-slow) seems to hint that the HTTP library from Android my be the culprit. Therefore, it may be your client devices that are slow, not the server. Easy way to test - use a non-android device to upload a file.
Thanks Oliver A. The client side is a Windows PC using the Chrome web browser. HTTPServer uses the Jetty Server. I'm thinking this may be what slows the upload speed down. Oddly enough, download speed is not affected.

Regards
 
Upvote 0

William Hunter

Active Member
Licensed User
Longtime User
For those interested. I mentioned WiFi File Transfer Pro in post #3 above, as being very fast in both upload and download speeds. I was curious as to whether this app used jetty server, or otherwise. I had a peek into its assets folder to see if elements of jetty server were present. The app does not use jetty server, but instead is built around the mootools project, using mootools.js and other associated elements.

Going further with this is beyond my skill level, but it may be of interest to those wishing to develop a wifi file transfer app with better performance than HTTPServer can provide. In this instance it does not appear that base64 encoding has any degrading affect on upload speed.

Best regards :)
 
Last edited:
Upvote 0
Top