- java.lang.Object
-
- io.netty5.handler.timeout.WriteTimeoutHandler
-
- All Implemented Interfaces:
io.netty5.channel.ChannelHandler
public class WriteTimeoutHandler extends Object implements io.netty5.channel.ChannelHandler
Raises aWriteTimeoutException
when a write operation cannot finish in a certain period of time.// The connection is closed when a write operation cannot finish in 30 seconds. public class MyChannelInitializer extends
ChannelInitializer
<Channel
> { public void initChannel(Channel
channel) { channel.pipeline().addLast("writeTimeoutHandler", newWriteTimeoutHandler
(30); channel.pipeline().addLast("myHandler", new MyHandler()); } } // Handler should handle theWriteTimeoutException
. public class MyHandler implementsChannelHandler
{@Override
public void exceptionCaught(ChannelHandlerContext
ctx,Throwable
cause) throwsException
{ if (cause instanceofWriteTimeoutException
) { // do something } else { super.exceptionCaught(ctx, cause); } } }ServerBootstrap
bootstrap = ...; ... bootstrap.childHandler(new MyChannelInitializer()); ...- See Also:
ReadTimeoutHandler
,IdleStateHandler
-
-
Constructor Summary
Constructors Constructor Description WriteTimeoutHandler(int timeoutSeconds)
Creates a new instance.WriteTimeoutHandler(long timeout, TimeUnit unit)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
handlerRemoved(io.netty5.channel.ChannelHandlerContext ctx)
io.netty5.util.concurrent.Future<Void>
write(io.netty5.channel.ChannelHandlerContext ctx, Object msg)
protected void
writeTimedOut(io.netty5.channel.ChannelHandlerContext ctx)
Is called when a write timeout was detected-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty5.channel.ChannelHandler
bind, channelActive, channelInactive, channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, exceptionCaught, flush, handlerAdded, read, register, userEventTriggered
-
-
-
-
Method Detail
-
write
public io.netty5.util.concurrent.Future<Void> write(io.netty5.channel.ChannelHandlerContext ctx, Object msg)
- Specified by:
write
in interfaceio.netty5.channel.ChannelHandler
-
handlerRemoved
public void handlerRemoved(io.netty5.channel.ChannelHandlerContext ctx) throws Exception
- Specified by:
handlerRemoved
in interfaceio.netty5.channel.ChannelHandler
- Throws:
Exception
-
-