I am receiving JSON Data from a client application, but once in a while the HTTP content length is above 64K, and I receive the following error:
org.jboss.netty.handler.codec.frame.TooLongFrameException: HTTP content length exceeded 65536 bytes.
I currently have the following, rather naive, implementation in place to read the HTTP contents:
String requestContent = null;
HttpRequest request = (HttpRequest) e.getMessage();
ChannelBuffer content = request.getContent();
if (content.readable()) {
requestContent = content.toString(CharsetUtil.UTF_8);
}
Is there a way to enable receiving more than 64K of data ?
Edit: Stack Trace:
Aug 31, 2012 2:35:20 PM org.jboss.netty.channel.SimpleChannelUpstreamHandler
WARNING: EXCEPTION, please implement org.eurekaj.manager.server.router.RouterHandler.exceptionCaught() for proper handling.
org.jboss.netty.handler.codec.frame.TooLongFrameException: HTTP content length exceeded 65536 bytes.
at org.jboss.netty.handler.codec.http.HttpChunkAggregator.messageReceived(HttpChunkAggregator.java:130)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.unfoldAndFireMessageReceived(ReplayingDecoder.java:593)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:584)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:509)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:94)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.processSelectedKeys(AbstractNioWorker.java:372)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:246)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:38)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
This, again cause the following error in my application, which indicated that only the first 64K of data is read from the HTTP request:
Caused by: org.json.JSONException: Unterminated string at character 65537
at org.json.JSONTokener.syntaxError(JSONTokener.java:410)
at org.json.JSONTokener.nextString(JSONTokener.java:244)
Ok then specify a different max content length in the constructor of HttpChunkAggregator. That should do the trick..