Android httpclient file upload data corruption and timeout issues

前端 未结 3 1567
说谎
说谎 2020-11-30 11:44

i\'m having issues with uploading images in android.

i\'m using apache httpmime 4.1 lib the code is like this:

MultipartEntity reqEntity = new Multip         


        
3条回答
  •  执笔经年
    2020-11-30 12:14

    ok. spent 2 days on testing this issue and found out following:
    when using tcpdump on android it comes that the data wasn't corrupt, BUT the tcp packet size was 1516, which is very strange, cause the normal ethernet packet size is 1500 and everything more than 1516 is way too big.
    i manually changed the MTU to 576 (i believe it is the standard for ppp, which 3G actually is) and it works perfect! 150 of 150 images were uploaded normally!

    this doesn't solve the actual problem, though, cause it's impossible to change mtu on non-rooted devices i believe, and you have to change it every time you reboot the device (or every time you bring up the interface - not sure about it, cause couldn't find the way of getting MTU value via ifconfig). but at least i know where the problem is.
    setting http chunk size to a smaller value (tried 300 bytes) didn't affect it (i believe it's because the http headers are way too big themselves)... so... so nothing =)

    will try to post it to android-developer group on google, but their moderation is way too slow... we'll see...

提交回复
热议问题