IdleStateHandler
"Trustin Lee (이희승)"
trustin at gmail.com
Mon Jan 25 04:33:02 EST 2010
Hello Michael,
Yes, you have to insert it into the pipeline instead of extending it.
You seem to have found the answer already. :)
IdleStateEvent will be triggered by IdleStateHandler. You can catch it
by modifying your handler (CommandHandler) to extend
IdleStateAwareChannelUpstreamHandler.
HTH,
Trustin
Michael Matthews wrote:
> I am trying to figure out what the correct way to use the
> IdleStateHandler is. I want my
> client connections to timeout so I had my handler extend
> IdleStateHandler rather than
> SimpleChannelUpstreamHandler. However, I found the connections were
> timing out
> even if they were being used. It looks like I have to forward calls to
> messageReceived to
> the IdleStateHandler class in order for the timeout to be reset.
>
> Now I'm wondering if I should have added the IdleStateHandler separately
> to the
> pipeline and add my handler afterwards modifying it to extend
> SimpleChannelUpstreamHandler.
>
> Currently my pipeline factory looks like:
> -------------------
> ChannelPipeline p = Channels.pipeline();
>
> p.addLast("frameDecoder", new
> LengthFieldBasedFrameDecoder(1048576, 0, 4, 0, 4));
> p.addLast("protobufDecoder", new
> ProtobufDecoder(Requests.Request.getDefaultInstance()));
>
> p.addLast("frameEncoder", new LengthFieldPrepender(4));
> p.addLast("protobufEncoder", new ProtobufEncoder());
>
> p.addLast("pipelineExecutor", new ExecutionHandler(executor));
> p.addLast("handler", new CommHandler(server));
> return p;
> -----------------
> Where CommHandler is my sub-class of IdleStateHandler
>
> I'm wondering if I should change it to something like:
> -----------------------
> ChannelPipeline p = Channels.pipeline();
>
> p.addLast("frameDecoder", new
> LengthFieldBasedFrameDecoder(1048576, 0, 4, 0, 4));
> p.addLast("protobufDecoder", new
> ProtobufDecoder(Requests.Request.getDefaultInstance()));
>
> p.addLast("frameEncoder", new LengthFieldPrepender(4));
> p.addLast("protobufEncoder", new ProtobufEncoder());
>
> p.addLast("pipelineExecutor", new ExecutionHandler(executor));
> p.addLast("handler", new IdleStateHandler(....));
> p.addLast("handler", new CommHandler(server));
> return p;
> ----------------------
>
> Any thoughts? Does any of that make sense? I've only had half a cup of
> coffee
> this morning so the brain is barely functioning.
>
>
> Michael Matthews
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
--
what we call human nature in actuality is human habit
http://gleamynode.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100125/2b9eca1d/attachment.bin
More information about the netty-users
mailing list