私はnetty-3.5.11.Final.jarを使用しています
私のブートストラップは次のようになります。
val bootstrap = new ServerBootstrap(channelFactory)
bootstrap.getPipeline.addLast("httpDecoder", new HttpRequestDecoder())
bootstrap.getPipeline.addLast("aggregator", new HttpChunkAggregator(1024 * 1024 * 1024))
bootstrap.getPipeline.addLast("httpEncoder", new HttpResponseEncoder())
bootstrap.getPipeline.addLast("deflater", new HttpContentCompressor())
bootstrap.getPipeline.addLast("handler", new HttpRequestServerHandler())
bootstrap.setOption("child.tcpNoDelay", true)
bootstrap.setOption("child.keepAlive", true)
私handlePost()
は次のように見えます:
def handlePost(context: ChannelHandlerContext, request: HttpRequest) = {
val response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK)
val body: Array[Byte] = ....
response.setContent(ChannelBuffers.wrappedBuffer(body))
context.getChannel.write(response)
context.getChannel.close
}
260000バイトの長さの本文を送信しようとすると、正しく送信されます。より大きなバイト配列を送信すると、次の例外が発生します。
java.nio.channels.ClosedChannelException
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.cleanUpWriteBuffer(AbstractNioWorker.java:766)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.close(AbstractNioWorker.java:734)
at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.handleAcceptedSocket(NioServerSocketPipelineSink.java:111)
at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.eventSunk(NioServerSocketPipelineSink.java:66)
at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:54)
at org.jboss.netty.channel.Channels.close(Channels.java:820)
at org.jboss.netty.channel.AbstractChannel.close(AbstractChannel.java:197)
at com.lendingblocks.services.ServiceServer$HttpRequestServerHandler.messageReceived(ServiceServer.scala:65)
at org.jboss.netty.handler.codec.http.HttpContentEncoder.messageReceived(HttpContentEncoder.java:81)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
at org.jboss.netty.handler.codec.http.HttpChunkAggregator.messageReceived(HttpChunkAggregator.java:192)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:448)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:538)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:437)
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:84)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.processSelectedKeys(AbstractNioWorker.java:471)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:332)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:35)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
なぜこのエラーが発生するのですか?どうすれば修正できますか?