mirror of
https://gitee.com/wujiawei1207537021/wu-lazy-cloud-network.git
synced 2026-02-04 15:05:54 +08:00
[update] 显式指定注解处理器,4.x
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user