When can a ReadTimeout occur?

infectedrhytms infectedrhythms at hotmail.com
Mon May 10 19:10:20 EDT 2010


Ok it seems that I have fixed my timeout resources issues.

1- I using the Netty default ReadtimeoutHandler
2- Made sure the ReadTimeoutHandler is placed before potential blocking
handler, otherwise ReadtimeoutHandler will never get a "MessageRceived"

So the question is when does ReadTimeout happen?

Currently I have setup Jmeter to stress my application and once in a while I
get a ReadTimeout error, also from those few I get a ClosedChannelException.

a) Is Readtimeout happening because the stress test? JMeter is sending over
and over the same message.
b) How is the ClosedChannelException hapening? The exception happens before
I write to the socket or does it?


The pipeline...

pipeline.addLast("timeout", new ReadTimeoutHandler(timer, readTimeout,
TimeUnit.SECONDS));		
pipeline.addLast("framer", new
IntegerHeaderFrameDecoder(Constants.DefaultLengthHeader));
pipeline.addLast("StringDecoder", StringDecoder);
pipeline.addLast("StringEncoder", StringEncoder);
pipeline.addLast("threaded", executionHandler);
pipeline.addLast("Myencoderdecoder", new MessageEncoderDecoder());
pipeline.addLast("MyDHandler", new MHandler());


Some info on my handlers...

- The IntegerHeaderFrameDecoder implements FrameDecoder decode and just
returns null or a frame.

- MyMessageEncoderDecoder implements SimpleChannelHandler handleUpstream,
handleDownStream witch writes to the channel <--- MyHandler closes the
connection on Exception, could this be it? But the ClosedChannelException 
happens on MyHandler not on my encoder/decoder which btw also overrides
ExceptionCaught

And the business hanlder itself....

public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
throws Exception {
		
	Channel ch = e.getChannel();
		
	// Do something fairly long here averages about 3-4 seconds
		
	ChannelFuture cf = ch.write(responseMessage);
		
	// Will close the channel once the write is done.
	cf.addListener(ChannelFutureListener.CLOSE);
}

@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
		
	Channel ch = ctx.getChannel();

	ch.close(); <-- Could this cause the ClosedChannelException ? But why would
ClosedChannelException get caught here and not downstream?

		
	logHelper.logError(e.getCause());
}

Just curious to know what happens!




-- 
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/When-can-a-ReadTimeout-occur-tp5033507p5033507.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list