Why ReadTimeout threw instead of IdleTimeout? How to throw IdleTimeout?
"이희승 (Trustin Lee)"
trustin at gmail.com
Thu Aug 6 02:31:41 EDT 2009
Hello Huican,
It's ReadTimeoutHandler that throws ReadTimeoutException. It's not
related with IdleState at all. It's IdleStateHandler that triggers
IdleStateEvent. Perhaps you don't need a ReadTimeoutHandler in the
pipeline?
To see how you can handle IdleStateEvent, please refer to the source
code of IdleStateAwareChannelHandler.
HTH,
Trustin
On 08/06/2009 07:47 AM, Huican Ping wrote:
>
> Hello Trustin,
>
> In my client application, I have IdleStateHalder, ReadTimeoutHandler and
> WriteTimeoutHandler added like below:
> ===========
> pipeline.addLast("idle", new IdleStateHandler(timer, 0, 0, idleTimeout));
> pipeline.addLast("readTimeout", new ReadTimeoutHandler(timer,
> responseTimeout,
> TimeUnit.SECONDS));
> pipeline.addLast("writeTimeout", new WriteTimeoutHandler(timer,
> sendTimeout,
> TimeUnit.SECONDS));
>
>
> On the Client code, after I got the last chunk, I put the channel
> (connection) into a pool, and later I can re-use them.
> FYI, This client didn't close the connection. And also the backend server
> doesn't close the connection also.
> Both of them are "ESTABLISHED" state.
>
> if (chunk.isLast())
> {
> readingChunks = false;
>
> if (keepAlive == true)
> {
> conn.release(); // put back the channel back into a pool.
> }
>
>
> After a while, I saw the exception throw, and it is ReadTimeout, but not
> IdleTimeout.
>
> Exception:
> org.jboss.netty.handler.timeout.ReadTimeoutException^M
> at
> org.jboss.netty.handler.timeout.ReadTimeoutHandler.<clinit>(ReadTimeoutHandler.java:62)^M
> at
> com.acme.http.ia.ClientPipelineFactory.getPipeline(ClientPipelineFactory.java:92)^M
> at
> org.jboss.netty.bootstrap.ClientBootstrap.connect(ClientBootstrap.java:226)^M
> at
> org.jboss.netty.bootstrap.ClientBootstrap.connect(ClientBootstrap.java:199)^M
>
> Questions:
> 1) Why it is ReadTimeout, not idleTime?
> 2) How can I let it throw idleTimeout?
More information about the netty-users
mailing list