Please give me advice how to increase my ByteBuf initial capacity.
In situation like:
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
byte[] byteinput = new byte[in.readableBytes()];
in.readBytes(byteinput);
//further handling...
}
If income message more than max capacity of ByteBuf - i get cutted data. Its vital for this project to get whole, non chunked message.
I suppose i need to set initial capacity of ByteBuf somewhere in bootstraps childOptions, or in cannel.config()... inside of ChannelInitializer.
And i tried different ways like setting
ch.config().setReceiveBufferSize(1024)
but i still have same value of ByteBuf capacity(e.g. 496).
UPD
I discovered my protocol traffic with wireshark, and packets up to 1,4k going uncorrupted out and in from my test user client. This issue is only matter of netty settings. Operating system socket buffer do not cuts messages.
That was easy as pie.
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());
.
.
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With