Infinite error loop on read time out.

infectedrhytms infectedrhythms at hotmail.com
Thu May 6 14:48:30 EDT 2010


Ok here is my ReadtimeOutHandler implementation with the call to super. Also
it doesn't seem to call MessageReceived...

@ChannelPipelineCoverage("one")
public class RequestReadTimeoutHandler extends ReadTimeoutHandler {

	private static final LogHelper logHelper = LogHelper.getInstance();
	
	public RequestReadTimeoutHandler(Timer timer, int timeoutSeconds) {
		super(timer, timeoutSeconds);
		// TODO Auto-generated constructor stub
	}

	@Override
	//In case of read timeout,send back a response and close the channel 
	protected void readTimedOut(ChannelHandlerContext ctx) {
		logHelper.logError("Read timeout error...");
		ChannelFuture cf =
ctx.getChannel().write(Constants.MPIRequestTooShortResponse);

		// Will close the channel once the write is done.
		cf.addListener(ChannelFutureListener.CLOSE);
		releaseExternalResources();
	}

	//It has already been processed, do not need to timeout again
	@Override
	public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
throws Exception
	{
		System.out.println("1...");

		super.messageReceived(ctx, e);

		Object message = e.getMessage();
		
		logHelper.debug(message.getClass().toString());
		
		System.out.println("2...");
		
		if (message instanceof String)
		{
			System.out.println("3...");
			if(((String) message).length()>Constants.DefaultLengthHeader)
				releaseExternalResources();
		}
		
		Channels.fireMessageReceived(ctx, message);
		System.out.println("4...");

	}
	
	@Override
	public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
		System.out.println("There...");

		e.getCause().printStackTrace();
		
		Channel ch = e.getChannel();
		ch.close();		
	}

}
-- 
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Infinite-error-loop-on-read-time-out-tp5008996p5015893.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list