@Override public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) { if (e.getState() == IdleState.WRITER_IDLE && enabledTimeout) { e.getChannel().close(); } } }
@Override public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception { if(e.getState() == IdleState.ALL_IDLE){ LOG.warn("Channel {} has been idle, it will be disconnected now: ",e.getChannel()); e.getChannel().close(); } }
@Override public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) { logger.info("In IDLE event handler for TCP..."); //there are 3 states. READER/WRITER/ALL if (e.getState() == IdleState.ALL_IDLE){ int statusCodeInt = 0; String statusCode = statusCodeInt + " SUCCESSFUL"; String errMsg="idleTimeout to finish"; tcpWorker.onComplete(tcpWorker.responseSb.toString(), false, errMsg, errMsg, statusCode, statusCodeInt); } } }
/** * this case is like a read timeout where did not get anything from the * server for a long time. * * For UDP need to mark as error * * @see org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler#channelIdle * (org.jboss.netty.channel.ChannelHandlerContext, * org.jboss.netty.handler.timeout.IdleStateEvent) */ @Override public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) { logger.debug("In IDLE event handler for UDP..timeout."); // there are 3 states. READER/WRITER/ALL if (e.getState() == IdleState.ALL_IDLE) { int statusCodeInt = 1; String statusCode = statusCodeInt + " FAILURE"; String errMsg = "UDP idle (read) timeout"; udpWorker.onComplete(udpWorker.responseSb.toString(), true, errMsg, errMsg, statusCode, statusCodeInt); } } }
@Override public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) { logger.info("In IDLE event handler for TCP..."); //there are 3 states. READER/WRITER/ALL if (e.getState() == IdleState.ALL_IDLE){ int statusCodeInt = 0; String statusCode = statusCodeInt + " SUCCESSFUL"; String errMsg="idleTimeout to finish"; tcpWorker.onComplete(tcpWorker.responseSb.toString(), false, errMsg, errMsg, statusCode, statusCodeInt); } } }
/** * this case is like a read timeout where did not get anything from the * server for a long time. * * For UDP need to mark as error * * @see org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler#channelIdle * (org.jboss.netty.channel.ChannelHandlerContext, * org.jboss.netty.handler.timeout.IdleStateEvent) */ @Override public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) { logger.debug("In IDLE event handler for UDP..timeout."); // there are 3 states. READER/WRITER/ALL if (e.getState() == IdleState.ALL_IDLE) { int statusCodeInt = 1; String statusCode = statusCodeInt + " FAILURE"; String errMsg = "UDP idle (read) timeout"; udpWorker.onComplete(udpWorker.responseSb.toString(), true, errMsg, errMsg, statusCode, statusCodeInt); } } }
public class IdleStateAwareHandler extends IdleStateAwareChannelHandler { @Override public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) { if (e.getState() == IdleState.READER_IDLE) { e.getChannel().write("heartbeat-reader_idle"); } else if (e.getState() == IdleState.WRITER_IDLE) { Logger.getLogger(IdleStateAwareHandler.class.getName()).log( Level.WARNING, "WriteIdle detected, closing channel"); e.getChannel().close(); e.getChannel().write("heartbeat-writer_idle"); } else if (e.getState() == IdleState.ALL_IDLE) { e.getChannel().write("heartbeat-all_idle"); } } }
@Override public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) { if (e.getState() == IdleState.WRITER_IDLE && enabledTimeout) { e.getChannel().close(); } } }
@Override public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception { if (e.getState() == IdleState.ALL_IDLE) { e.getChannel().close(); } }
@Override public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) { if (e.getState() == IdleState.WRITER_IDLE && enabledTimeout) { e.getChannel().close(); } } }
@Override public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception { if (e.getState() == IdleState.ALL_IDLE) { throw new SMTPIdleException("Connection was idling for " + (System.currentTimeMillis()- e.getLastActivityTimeMillis()) + " ms"); } super.channelIdle(ctx, e); }
@Override public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception { if (e.getState().equals(IdleState.WRITER_IDLE)) { e.getChannel().write(ChannelBuffers.wrappedBuffer("* OK Hang in there..\r\n".getBytes("US-ASCII"))); } super.channelIdle(ctx, e); }
@Override public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception { if (!isHandshakeComplete()) { return; } if (e.getState() == IdleState.READER_IDLE) { // When no message is received on channel for read timeout, then close // the channel log.info("Disconnecting client {} due to read timeout", getClientInfoString()); ctx.getChannel().close(); } else if (e.getState() == IdleState.WRITER_IDLE) { // Send keep alive message log.debug("Sending keep alive message due to IdleState timeout " + pc.toString()); pc.sendMessage(Collections.singletonList(pc.factory().buildKeepaliveMsg().build())); } }
@Override public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception { if (!isHandshakeComplete()) { return; } if (e.getState() == IdleState.READER_IDLE) { // When no message is received on channel for read timeout, then close // the channel log.info("Disconnecting client {} due to read timeout", getClientInfoString()); ctx.getChannel().close(); } else if (e.getState() == IdleState.WRITER_IDLE) { // Send keep alive message log.debug("Sending keep alive message due to IdleState timeout " + pc.toString()); pc.sendMessage(Collections.singletonList(pc.factory().buildKeepaliveMsg().build())); } }
@Override public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception { LOG.info("closing {} channel after {} event was intercepted", channelName, e.getState().toString()); e.getChannel().close().addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { if (future.isSuccess()) { LOG.info("{} channel closed cleanly", channelName); } else { LOG.info("{} channel failed to close cleanly", channelName); } } }); }
@Override public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception { if (e.getState() == IdleState.ALL_IDLE) { idle_connections_closed.increment(); LOG.info("Closing idle connection to HBase region server: " + e.getChannel()); // RegionClientPipeline's disconnect method will handle cleaning up // any outstanding RPCs and removing the client from caches try { e.getChannel().close(); } catch (Exception ex) { // This handler may be called after a channel has entered an odd state // or already been closed. If it has been closed properly, then ignore // the exception, otherwise throw it. if (!(ex instanceof ClosedChannelException)) { throw ex; } } } } }
@Override public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception { // check if the client did nothing for too long if (e.getState().equals(IdleState.ALL_IDLE)) { ImapSession session = (ImapSession) attributes.get(ctx.getChannel()); InetSocketAddress address = (InetSocketAddress) ctx.getChannel().getRemoteAddress(); LOGGER.info("Logout client {} ({}) because it idled for too long...", address.getHostName(), address.getAddress().getHostAddress()); // logout the client session.logout(); // close the channel ctx.getChannel().close(); } super.channelIdle(ctx, e); }
public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception { // just close idle connection if (e.getState() == IdleState.ALL_IDLE) { ChannelFuture future = ctx.getChannel().close(); future = future.await(); if (future.isSuccess()) { log.info("close idle connecton: client ip=>" + ctx.getChannel().getRemoteAddress()); } else { log.info("failure close idle connecton: client ip=>" + ctx.getChannel().getRemoteAddress()); } } } }