[update] 显式指定注解处理器,4.x

This commit is contained in:
wujiawei
2026-01-07 14:32:30 +08:00
parent 4d6c5fcbd7
commit 0c6fb1680a
4 changed files with 56 additions and 1 deletions

View File

@@ -48,7 +48,13 @@ public class NettySocketProtocolHandleSocketLocalProxyTypeAdvanced
b.group(group)
.channel(NioSocketChannel.class)
.option(ChannelOption.TCP_NODELAY, true)
.option(ChannelOption.SO_KEEPALIVE, true) // 开启TCP保活检测无效连接
.option(ChannelOption.TCP_NODELAY, true) // 关闭Nagle算法适配直播流低延迟
.option(ChannelOption.SO_RCVBUF, 2048 * 1024)// 设置读缓冲区为2M
.option(ChannelOption.SO_SNDBUF, 1024 * 1024)// 设置写缓冲区为1M
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000 * 60)//连接超时时间设置为 60 秒
.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(1024 * 1024, 1024 * 1024 * 2))
.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {

View File

@@ -83,6 +83,7 @@ public class NettySocketBackendHandler extends SimpleChannelInboundHandler<Netty
if (nextChannel.isActive()) {
nextChannel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
}
super.channelInactive(ctx);
}
@Override

View File

@@ -1,6 +1,8 @@
package org.framework.lazy.cloud.network.heartbeat.protocol.handler;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.socket.nio.NioDatagramChannel;
@@ -107,6 +109,17 @@ public class NettySocks5CommandRequestHandler extends SimpleChannelInboundHandle
}
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
log.trace("代理通道与客户通道断开,即将断开客户端和代理服务器的连接");
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(ctx.channel());
if (nextChannel.isActive()) {
nextChannel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
}
super.channelInactive(ctx);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
cause.printStackTrace();