我做了一个骆驼netty4服务器程序。客户端发送1119字节的消息,但我的解码器截断1024/95骆驼netty4消息1024截断..如何解决它?
这里是我的代码。
@ChannelHandler.Sharable
public static class BytesDecoder extends MessageToMessageDecoder<ByteBuf> {
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) throws Exception {
System.out.println("BytesDecoder readableBytes:"+msg.readableBytes());
if (msg.isReadable()) {
byte[] bytes = new byte[msg.readableBytes()];
int readerIndex = msg.readerIndex();
msg.getBytes(readerIndex, bytes);
out.add(bytes);
}
}
}
结果===>
BytesDecoder readableBytes:1024
BytesDecoder readableBytes:95
我希望得到一个完整的邮件字节1119字节。
检查有关这些编解码器的netty文档,它们很可能具有1024的默认限制,您需要重新配置为更高的值等。 –