ByteBuf初始容量大小

Asp*_*lis 3 java netty

请给我建议如何增加ByteBuf的初始容量。
在这样的情况下:

 @Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws  Exception {

    byte[] byteinput = new byte[in.readableBytes()]; 
    in.readBytes(byteinput);  

//further handling...
}
Run Code Online (Sandbox Code Playgroud)

如果收入消息超过ByteBuf的最大容量-我将得到削减的数据。对于整个项目而言,获得完整的,非分块的消息至关重要。

我想我需要在引导子选项OptionOptions或在ChannelInitializer内部的cannel.config()中设置ByteBuf的初始容量。
我尝试了不同的方法,例如设定

ch.config().setReceiveBufferSize(1024)
Run Code Online (Sandbox Code Playgroud)

但我仍然具有相同的ByteBuf容量值(例如496)。

UPD

我发现了使用Wireshk进行的协议通信,以及从测试用户客户端传入和传出的1,4k数据包都未损坏。此问题仅与净值设置有关。操作系统套接字缓冲区不会剪切消息。

Asp*_*lis 5

就像馅饼一样简单。

ServerBootstrap b = new ServerBootstrap(); // (2)
        b.group(bossGroup, workerGroup)
                .channel(NioServerSocketChannel.class) // (3)
                .childHandler(new ChannelInitializer<SocketChannel>() { // (4)
                    @Override
                    public void initChannel(SocketChannel ch) throws Exception {

                        //decrypt  //checknum

                        ch.config().setRecvByteBufAllocator(new FixedRecvByteBufAllocator(2048)); //set  buf size here
                         ch.pipeline().addLast(new InboundDecryptor());
 .
 .
 .
Run Code Online (Sandbox Code Playgroud)