Christopher Perry
Christopher Perry

Reputation: 39255

HttpUrlConnection Keep Alive doesn't work correctly

I set up an HttpUrlConnection and set the system properties for a single keep alive connection per the documentation:

System.setProperty("http.keepAlive", "true");
System.setProperty("http.maxConnections", "1");

Android simply ignores these. I'm seeing connections on multiple ports at the same IP for http traffic in wireshark. Am I missing something or is this just broken on Android? I've tried on Android-L and also Android-M preview, it's broken on both.

Upvotes: 1

Views: 832

Answers (1)

wshztlg
wshztlg

Reputation: 181

Which version of Android do you use, in some versions of Android, there is a bug about socket reuse, please refer to the following links.

https://code.google.com/p/android/issues/detail?id=38817 https://code.google.com/p/android/issues/detail?id=43132#makechanges

and maybe you can try to remove the gzip content type to avoid the bug.

Upvotes: 1

Related Questions