Clients crashing a Netty Server using LengthFieldBasedFrameDecoder

Christian Migowski chrismfwrd at gmail.com
Fri Oct 16 07:41:32 EDT 2009


sorry, maybe it isn't clear, with the Handler class I am adding I mean
the LengthFieldBasedFrameDecoder class



On Fri, Oct 16, 2009 at 1:38 PM, Christian Migowski
<chrismfwrd at gmail.com> wrote:
> Hi,
>
>
> On Fri, Oct 16, 2009 at 1:10 PM, phi6 <phidinh6 at gmail.com> wrote:
>>
>>
>> Thanks for that Christian, so I understand FrameDecoder is one per channel
>> as specified in the annotation, so why am I getting this issue?
>
> Netty doesn't enforce that there is one per Channel, it is up to you!
> I guess your server setup looks something like this:
>
>        ServerBootstrap bootstrap = new ServerBootstrap(factory);
>
>        ChannelPipeline pipeline = bootstrap.getPipeline();
>        pipeline.addLast("handler", new Handler());
> ...
>        bootstrap.bind(new InetSocketAddress(...));
>
>
> but this is not correct, it should be something like
>
>        ServerBootstrap bootstrap  = new ServerBootstrap(factory);
>        bootstrap.setPipelineFactory(new ServerPipelineFactory());
> ...
>        bootstrap.bind(new InetSocketAddress(...));
>
> where ServerPipelneFactory is something like
>
>   class ServerPipelineFactory implements ChannelPipelineFactory {
>        public ChannelPipeline getPipeline() throws Exception {
>            ChannelPipeline pipeline = Channels.pipeline();
>            pipeline.addLast("handler", new Handler());
>            return pipeline;
>        }
>    }
>
> That way, each time the server accepts a new channel, it gets a new
> pipeline with a new Handler instance.
>
> I think it is pretty good covered in the user guide, if you haven't
> yet, you should definitivly read it!
>
> hth,
> regards,
> christian!
>
>
>
>
>> Could you explain the following a bit more:
>>
>>
>> christian wrote:
>>>
>>> So you need to use bootstrap.setPipelineFactory() instead of getting
>>> the default pipeline via bootstrap.getPipeline();
>>>
>>
>> Many thanks!
>>
>> --
>> View this message in context: http://n2.nabble.com/Clients-crashing-a-Netty-Server-using-LengthFieldBasedFrameDecoder-tp3834641p3834922.html
>> Sent from the Netty User Group mailing list archive at Nabble.com.
>> _______________________________________________
>> netty-users mailing list
>> netty-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/netty-users
>>
>



More information about the netty-users mailing list