netty 4.0.25 error: Duplicate handler name

206 views
Skip to first unread message

Tanima Saini

unread,
Feb 27, 2015, 8:58:19 AM2/27/15
to ne...@googlegroups.com
Hi,

I am using netty 4.0.25Final to write a netty HTTP server. Apart from http codecs, I have three "sharable" handlers say handler1, handler2 and handler 3. I am modifying netty pipeline when the server gets a http request based on a condition. My pipeline looks like:

pipeline.addLast(new HttpRequestDecoder(4096, 8192, 8192, false),
                     new HttpResponseEncoder(),
                     new HttpObjectAggregator(1048576),
                     handler1
                     ); 
pipeline
        .addLast("handler2", ExceptionHandler.getInstance());


In channelRead0 of handler1, based on a condition I add handler3 like:
ctx.pipeline().addBefore("handler2", "handler3", Handler3.getInstance());

I am trying to make 10 calls to my server with keep-alive= true using the following command
weighttp -c 1 -n 10 -k "http://localhost:8080/abc"

Some of the request gives the below exception:
[ERROR] 27 Feb 2015 12:33:52,370 (com.server.netty.Pipeline.ExceptionHandler:exceptionCaught:49)

java.lang.IllegalArgumentException: Duplicate handler name: handler3
        at io.netty.channel.DefaultChannelPipeline.checkDuplicateName(DefaultChannelPipeline.java:959)
        at io.netty.channel.DefaultChannelPipeline.addBefore(DefaultChannelPipeline.java:159)
        at io.netty.channel.DefaultChannelPipeline.addBefore(DefaultChannelPipeline.java:151)
        at com.vdopia.rtb.netty.Pipeline.Handler1.channelRead0(RequestDecoder.java:156)
        at com.vdopia.rtb.netty.Pipeline. Handler1.channelRead0(RequestDecoder.java:98)
        at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:182)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
        at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
        at java.lang.Thread.run(Thread.java:745)

The exception goes off if I do any of the following:
1. I remove keep-alive while making a call to the server
2. Dont use dynamic pipeline.

Has anybody encountered this error? It seems as if same pipeline is being used across some http requests. Please help me to resolve this issue.

Thanks & Regards,
Tanima
Reply all
Reply to author
Forward
0 new messages