Read timeout errors in infinite loop
javadevmtl
java.dev.mtl at gmail.com
Thu Aug 19 09:57:09 EDT 2010
Using Netty 3.2.1 Final and jdk 1.6u21
I set to stress my application for a couple of hours and I came back to find
out that it is accepting but NOT responding. Also, my client application has
finished sending and I'm seeing constant read timeout errors written to my
log.
CPU usage is at minimum. Also I can send to it seems to process but nothing
comes back.
The stack trace...
org.jboss.netty.handler.timeout.ReadTimeoutException
at
org.jboss.netty.handler.timeout.ReadTimeoutHandler.<clinit>(ReadTimeoutHandler.java:84)
at
com.mycom.services.broker.MyPipelineFactory.getPipeline(MPIPipelineFactory.java:53)
at
org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink$Boss.registerAcceptedChannel(NioServerSocketPipelineSink.java:276)
at
org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink$Boss.run(NioServerSocketPipelineSink.java:247)
at
org.jboss.netty.util.internal.IoWorkerRunnable.run(IoWorkerRunnable.java:46)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
The pipeline
pipeline.addLast("timeout", new ReadTimeoutHandler(timer, readTimeout,
TimeUnit.MILLISECONDS));
pipeline.addLast("framer", new
IntegerHeaderFrameDecoder(Constants.DefaultLengthHeader));
pipeline.addLast("threaded", executionHandler);
pipeline.addLast("decoder", new MyDecoder()); <-- Does simple DB insert log
time start.
pipeline.addLast("encoder", new MyEncoder()); <-- Does simple DB insert log
time end
pipeline.addLast("ThreeDHandler", new ThreeDHandler()); <-- Does some DB
CRUD
My Decoder function...
@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel, Object
msg) throws Exception {
if (!(msg instanceof ChannelBuffer)) {
return msg;
}
// By this point we have received the message correctly.
// Remove the timeout from the current pipeline so it it doesn't
// throw a ReadTimeoutException on a long running request.
ChannelPipeline cp = ctx.getPipeline();
cp.remove("timeout");
return decode(((ChannelBuffer)msg).toString(charset)); <-- Call my decode
function which takes a string.
}
My encoder...
@Override
protected Object encode(ChannelHandlerContext ctx, Channel channel, Object
msg) throws Exception {
if (!(msg instanceof MyResponseMessage)) {
return msg;
}
return ChannelBuffers.copiedBuffer((String)encode((MyResponseMessage)msg),
charset);
}
- If we don't add the ReadTimeoutHandler to the pipeline and the client
never sends the right data "protocol" how will the server know to discard
the connection or clean up? Do I really need to use ReadTimeout?
- If have to use ReadTimeOut, should I be removing the timeout from the
pipeline in my decoder as I shown in the above code? The only reason I do
this is because if the client finishes to send the data and then the server
takes a fair amount of time to process in between ReadTimeOut exceptions is
thrown because the client is no longer writting but waiting for the
response.
--
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Read-timeout-errors-in-infinite-loop-tp5440336p5440336.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list