您好,我有一个带有应该接受字符串的处理程序的 Netty 服务器。它似乎只接收最多 1024 字节的内容。我怎样才能增加缓冲区大小。我已经试过了
bootstrap.setOption("child.sendBufferSize", 1048576);
bootstrap.setOption("child.receiveBufferSize", 1048576);
没有成功。
处理程序如下
public class TestHandler extends SimpleChannelHandler {
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
ChannelBuffer buf = (ChannelBuffer) e.getMessage();
String response = "";
if (buf.readable()) {
response = buf.toString(CharsetUtil.UTF_8);
System.out.println("CONTENT: " + response);
}
System.out.println(response);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
e.getCause().printStackTrace();
Channel ch = e.getChannel();
ch.close();
}
}