Re: [android-developers] Re: Using AndroidHttpClient as a singleton.

2011-08-30 Thread Nathan
That is true. I don't expect to need more than 20 connections total, but possibly 3-6 connections per route; I don't know what is optimal yet. Nathan -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to

Re: [android-developers] Re: Using AndroidHttpClient as a singleton.

2011-08-29 Thread Nikolay Elenkov
On Tue, Aug 30, 2011 at 9:40 AM, Nathan wrote: > After forcing some errors and doing some debugging, I found that I was not > always calling entity.consumecontent() if I got an error, as you suggested > in another thread. If an actual exception is thrown, I hope I don't have to. > Nonetheless, if

[android-developers] Re: Using AndroidHttpClient as a singleton.

2011-08-29 Thread Nathan
After forcing some errors and doing some debugging, I found that I was not always calling entity.consumecontent() if I got an error, as you suggested in another thread. If an actual exception is thrown, I hope I don't have to. Nonetheless, if I get a status code other than 200, there can still b

[android-developers] Re: Using AndroidHttpClient as a singleton.

2011-08-29 Thread b0b
When an error (Exception) occurs you must call abort() on the request (ie your HttpGet or HttpPost instance). Also if you don't read (or read partially) the Entity in the response, you must call EntityUtils.consume(entity). Otherwise you may have hanging threads / connections. But I forgot to t

[android-developers] Re: Using AndroidHttpClient as a singleton.

2011-08-29 Thread Streets Of Boston
I found the same issue (actually, response-content from a previous request was 'bleeding' over into the next one). I solved this by make an AndroidHttpClient a ThreadLocal. This way, the number of AndroidHttpClients is never larger than the number of threads handling http-requests in the backgr

[android-developers] Re: Using AndroidHttpClient as a singleton.

2011-08-29 Thread Nathan
Well, I can say that it sounds really nice in theory. In practice, all you have to do is have a few requests fail, and then a subsequent request is completely frozen. The thread is then blocked on this call. ConnPoolByRoute.getEntryBlocking(HttpRoute, Object, long, TimeUnit, WaitingThreadAborter)

[android-developers] Re: Using AndroidHttpClient as a singleton.

2011-08-29 Thread b0b
In most apps AndroidHttpClient is best used a singleton for the reasons you describe. It doesn't make sense to create a thread pool for each AndroidHttpClient instantiation. >From the Apache HttpComponents dosc: "DefaultHttpClient is thread safe. It is recommended that the same instance of thi