Hello I have a Netty Server with a handler that should accept strings. It seems to only receive content up to 1024 bytes. How can i increase Buffer size. I have already tried
bootstrap.setOption("child.sendBufferSize", 1048576);
bootstrap.setOption("child.receiveBufferSize", 1048576);
without success.
The handler is as below
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();
}
}
Are you using UDP ? If so, packets will max out at 1024 bytes. This code comment is in the QOTM code sample:
If you are using TCP, you should add a frame decoder and a string decoder into your pipeline before yout handler; Something like this:
Mind you, you will need to modify your test handler because the MessageEvent will actually contain your string.
Make sense ?