1

I have an app that needs to support Android 1.6+

Based on this article: http://android-developers.blogspot.com/2011/09/androids-http-clients.html

In my experience this bug: (from link)

Prior to Froyo, HttpURLConnection had some frustrating bugs. In particular, calling close() on a readable InputStream could poison the connection pool. Work around this by disabling connection pooling."

...

For Gingerbread and better, HttpURLConnection is the best choice. Its simple API and small size makes it great fit for Android. Transparent compression and response caching reduce network use, improve speed and save battery. New applications should use HttpURLConnection; it is where we will be spending our energy going forward."

I'm finding that for android sdk version 9-13 HttpUrlConnection is working great with keep alives and gzip. However on ICS the bugs from froyo and previous versions are back. The connection pool gets poisoned and starts throwing exceptions that the connection is already established trying to add request headers etc. This same code works great on sdk 9-13.

I've verified that this is on emulator and devices.

Is anyone else experiencing this same problem?

Community
  • 1
  • 1
radiofrequency
  • 873
  • 8
  • 19
  • 2
    I am not quite certain how you expect people to tell you if they are "experiencing this problem in their app" when you were disinclined to actually tell anyone what "this problem" actually is – CommonsWare Nov 26 '11 at 00:13
  • good point, i've updated the question – radiofrequency Nov 26 '11 at 18:48
  • @radiofrequency: I'm using API 8 which is Gingerbread. I am experiencing a problem when using HttpURLConneciton. When I switch my connecion from WiFi to 3g, the 2nd connection will wait eternally for response at getResponseCode(). The 1st connection is in WiFi and I was already able to get the response successfully before I establish the 2nd connection. It was solved when I disabled connection pooling. According to the blog post, the bug is present prior to Froyo so I'm not sure why I'm still experiencing a connection problem at Gingerbread. Any thought? – Arci Apr 23 '12 at 08:04
  • I am seeing the same issue, disabling keep-alive fixed it for me. – Darrell May 10 '12 at 16:58
  • Show a minimal test case. – tc. Mar 18 '13 at 16:29

0 Answers0