我做了一個駱駝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的默認限制,您需要重新配置爲更高的值等。 –