I've still been trying to find a solution to this, but I'm still
stuck. I've tried the following:

1. using SingleClientConnManager.
2. calling Thread.interrupt() before the HttpPost.abort() call.
3. setting HttpPost instance variable to null.
4. Shutting down the connection manager for both
SingleClientConnManager and ThreadSafeClientConnManager.

After calling abort, the httpClient execute() call seems to take an
random length of time to return and sometimes goes up to the socket
timeout.

I've looked at the following post, but it did not work for me.
http://devtcg.blogspot.com/2008/07/interruptible-io-example-using.html

The difference is I am doing a post to a server that does not return a
response immediately, but holds for a period. I want to call abort
during that period to close the connection immediately.

I saw the following comment in the above blog's sample code:

/* CAVEAT: HttpClient 3.x encapsulates the platform's connect()
                         * call in such a way that prevents interruption.  This 
has been
                         * corrected in HttpClient 4 alpha 4, however Android 
distributes
                         * an older version which does not work as expected.  
My sources at
                         * Google have clarified that the final 1.0 release 
will include
                         * the newest version so this should hopefully be a 
non-issue for
                         * production.
                         *
                         * For a discussion of this problem see the following 
thread
                         * concerning HttpClient 3.x:
                         *
                         * 
http://mail-archives.apache.org/mod_mbox/hc-httpclient-users/200506.mbox/%[email protected]%3e
                         */

So is this a bug that should be reported to the Android team? Or is
there something else I can do?

Thanks!

On Mar 24, 4:59 pm, tme <[email protected]> wrote:
> I am using a DefaultHttpClient and a ThreadSafeClientConnManager to
> share the httpClient across threads. That part is working well.
> However, when I execute an HttpPost in one thread, and call
> httpPost.abort() from another. It does not return immediately and
> continues blocking until the socket timeout is reached in most cases.
> Am I missing something else?
>
> I've tried using:
>
>          connectionManager.closeIdleConnections(30, TimeUnit.SECONDS);
>          connectionManager.closeExpiredConnections();
>
> But it did not help.
>
> Thanks!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to