@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { e.getCause().printStackTrace(System.err); RedisConnection conn = (RedisConnection) ctx.getChannel().getAttachment(); conn.releaseBroken(); /* * ChannelFuture future = ctx.getChannel().disconnect(); * future.addListener(new ChannelFutureListener() { * * @Override public void operationComplete(ChannelFuture cf) throws * Exception { RedisConnection conn = * (RedisConnection)cf.getChannel().getAttachment(); * conn.releaseBroken(); } }); */ }