3

I am using Apache DefaultHttpClient with HttpPut for file upload using REST API. It is very slow while running from windows, it sends 240 kb/seconds . But it sends 950 kb/seconds when i run the same file from MAC

I don't have any explicit conditions for windows and Mac OS.

Can any one help me to resolve this issue.

My Code:

HttpPut putRequest = new HttpPut("http://my.localhost.com:8888");
FileEntity reqEntity = new FileEntity("c:/test/test.zip","text/plain");
putRequest.setEntity(reqEntity);
putRequest.addHeader("X-Auth-Token",strToken);
httpResponse = client.execute(putRequest);
mResponseCode = httpResponse.getStatusLine().getStatusCode();
Shishir Kumar
  • 7,981
  • 3
  • 29
  • 45

4 Answers4

3

Java is Write once, run anywhere (WORA). Hence, reason behind slower HTTP connection on Windows machine than a Mac machine has nothing to do with Java.

There can be several Windows machine woes which can slow the upload speed. I would suggest you to run below commands sequentially on the elevated command prompt.

To disable Receive-side Scaling:

netsh interface tcp set global rss=disabled

To disable TCP/IP auto-tuning:

netsh interface tcp set global autotuninglevel=disabled

To disable all Task offloads:

netsh int ip set global taskoffload=disabled

More details about above commands can be found here.

If the issue still persists, then you should

  1. Reinstall the network driver for the test.
  2. Boot in to Safe Mode with networking to check the result. If it works fine, please check the result in Clean Boot to check which third party tool affect this.

Shishir

Shishir Kumar
  • 7,981
  • 3
  • 29
  • 45
2

Do you have an antivirus application running on the windows machine? Try to disable if first and see if there is any difference.

otc
  • 694
  • 1
  • 9
  • 40
0

I would try this this command.

netsh int tcp set global autotuninglevel=disabled

If it doesn't make a difference, just re-enable it

netsh int tcp set global autotuninglevel=enabled

autotuning sometimes causes issues with TCP on Windows (and frankly I don't have any idea what it really does) but it caused me some similar problems in that past so, maybe it's worth a try. Honnestly it could be a lot of things.

You have to reboot tho after changing it.

alex
  • 343
  • 1
  • 2
  • 8
  • 1
    If you encourage someone to execute some shell code you better explain what it is doing. – Bart Mar 17 '14 at 19:50
  • 1
    Yes of course, I tend to forgot I'm still on the interwebz when I'm here sorry. http://www.aip.im/2012/10/how-to-disable-receive-window-auto-tuning-level/ This is the clearest description I could find in 5 minutes. As for myself I did run this on my personnal computer because a random guy on tomshardware told me it might work. And it did, so do what want with this. – alex Mar 18 '14 at 13:27
  • Here, I found a support page on microsoft describing a bit better (and it's also a bit more official than the previous blog I linked ;) ) : https://support.microsoft.com/kb/947239 – alex Mar 18 '14 at 13:32
0

I think your problem is related to the driver of the NIC and not Java.

Go to Start->Control Panel->Device Manager->Network adapters->Your Network Card, right-click then select Properties.

Go to the Advanced Tab.

Play with the settings there, which are specific to your NIC, so we can't really help you with the exact setting to play with. You may have something called "Large Send Offload (IPv4)" that can be disabled.

Seen here : Slow upload speeds on Windows 7

Community
  • 1
  • 1
Guillaume Serre
  • 307
  • 2
  • 8