3
我從客戶端應用接收JSON數據,但一旦在一段時間的HTTP內容長度超過64K,並且收到以下錯誤:Netty的:與HTTP內容長度錯誤超過64K
org.jboss.netty.handler.codec.frame.TooLongFrameException: HTTP content length exceeded 65536 bytes.
我目前有以下,比較幼稚,執行到位讀取HTTP內容:
String requestContent = null;
HttpRequest request = (HttpRequest) e.getMessage();
ChannelBuffer content = request.getContent();
if (content.readable()) {
requestContent = content.toString(CharsetUtil.UTF_8);
}
有沒有一種方法,使接收超過64K的數據?
編輯:堆棧跟蹤:
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)
這又導致在我的應用下面的錯誤,這表明,只有數據的第一個64K從HTTP請求讀:
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)
你可以請發佈完整的stacktrace? –
使用堆棧跟蹤編輯原始帖子。 –