Add WriteTimeoutHandler

This commit is contained in:
Outfluencer 2025-03-23 08:19:07 +11:00 committed by md_5
parent 4b0262312e
commit 687c302610
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
2 changed files with 7 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import io.netty.handler.codec.CorruptedFrameException;
import io.netty.handler.codec.DecoderException;
import io.netty.handler.codec.haproxy.HAProxyMessage;
import io.netty.handler.timeout.ReadTimeoutException;
import io.netty.handler.timeout.WriteTimeoutException;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.logging.Level;
@ -176,6 +177,9 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
if ( cause instanceof ReadTimeoutException )
{
ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - read timed out", handler );
} else if ( cause instanceof WriteTimeoutException )
{
ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - write timed out", handler );
} else if ( cause instanceof DecoderException )
{
if ( cause instanceof CorruptedFrameException )

View File

@ -23,6 +23,7 @@ import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.channel.unix.DomainSocketAddress;
import io.netty.handler.codec.haproxy.HAProxyMessageDecoder;
import io.netty.handler.timeout.ReadTimeoutHandler;
import io.netty.handler.timeout.WriteTimeoutHandler;
import io.netty.incubator.channel.uring.IOUring;
import io.netty.incubator.channel.uring.IOUringDatagramChannel;
import io.netty.incubator.channel.uring.IOUringEventLoopGroup;
@ -114,6 +115,7 @@ public class PipelineUtils
private static final ChannelAcceptor BASE_SERVERSIDE = new Base( true );
private static final KickStringWriter legacyKicker = new KickStringWriter();
public static final String TIMEOUT_HANDLER = "timeout";
public static final String WRITE_TIMEOUT_HANDLER = "write-timeout";
public static final String PACKET_DECODER = "packet-decoder";
public static final String PACKET_ENCODER = "packet-encoder";
public static final String BOSS_HANDLER = "inbound-boss";
@ -220,6 +222,7 @@ public class PipelineUtils
ch.pipeline().addLast( FRAME_DECODER, new Varint21FrameDecoder() );
ch.pipeline().addLast( TIMEOUT_HANDLER, new ReadTimeoutHandler( BungeeCord.getInstance().config.getTimeout(), TimeUnit.MILLISECONDS ) );
ch.pipeline().addLast( WRITE_TIMEOUT_HANDLER, new WriteTimeoutHandler( BungeeCord.getInstance().config.getTimeout(), TimeUnit.MILLISECONDS ) );
// No encryption bungee -> server, therefore use extra buffer to avoid copying everything for length prepending
// Not used bungee -> client as header would need to be encrypted separately through expensive JNI call
// TODO: evaluate difference compose vs two buffers