Why is Netty giving me only 768 Bytes from UDP messages

拟墨画扇 提交于 2019-12-03 16:04:58

You need to set an additional option - receiveBufferSizePredictorFactory.

in order to predict how much space it needs to allocate in order to hold the incoming message, netty uses a predictor that predicts the amount of byte to allocate.

there are two type of receive buffer size predictors, adaptive and fixed-size. the predictors are created by a predictor factory, which creates one for each channel created by the bootstrap.

if no predictor factory is set for the bootstrap (or no predictor is set manually for the channel), the channel uses the default 768 byte fixed-size predictor. all messages bigger then 768 bytes are cut down to that size.

you can add:

b.setOption("receiveBufferSizePredictorFactory", new FixedReceiveBufferSizePredictorFactory(1024));

you can read about the predictors and their factories in netty documentation

ReceiveBufferSizePredictor Inteface

ReceiveBufferSizePredictorFactory Inteface

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!