sonatype/async-http-client — Issue #48: sometimes I call AsyncHttpClient.execute but no response on the handler
Author: cplu
Created: 2012-02-01 06:25:53+00:00
State: open

I've post this problem on https://issues.sonatype.org/browse/AHC-120. Since no comments there I want to ask for help here.
I'm working on Android platform and I try to use this http client. The detail about this problem is below. I wonder if it is only exposed on Android.

I do sth like:
m_asyncHttpClient.prepareGet(http_url).setPerRequestConfig(request_config)	.setHeader("Connection", "Keep-Alive")
.setHeader("Accept-Language" , ...)
.execute(...)

with a AsyncHandler given as param.

If I do the above repeatly (several times) within a connected network situation, and a few times afterwards within a connected-less (no cable is connected) situation, then there's no callback function triggered.

I trace to the code and found that NettyAsyncHttpProvider's doConnect will create or get a future with a NettyConnectListener, whose operationComplete is called and "if (f.isSuccess())" is true, then "future.provider().writeRequest" is called.
in NettyAsyncHttpProvider's writeRequest,
"if (!channel.isOpen() || !channel.isConnected())" returns true, so it returns and no handler callback is triggered.

I use a ning of version 1.6.5. is it a known issue?