客户端重连优化

This commit is contained in:
aoshiguchen
2023-06-01 22:34:41 +08:00
parent 2d0b9132e9
commit e2195ab966
@@ -49,7 +49,7 @@ public class ProxyClientService {
/**
* 重连间隔(秒)
*/
private static final long RECONNECT_INTERVAL_SECONDS = 5;
private static final long RECONNECT_INTERVAL_SECONDS = 8;
/**
* 重连次数
*/
@@ -80,6 +80,14 @@ public class ProxyClientService {
bootstrap.group(workerGroup);
bootstrap.channel(NioSocketChannel.class);
bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000);
bootstrap.option(ChannelOption.SO_KEEPALIVE, true);
/**
* TCP/IP协议中,无论发送多少数据,总是要在数据前面加上协议头,同时,对方接收到数据,也需要发送ACK表示确认。为了尽可能的利用网络带宽,TCP总是希望尽可能的发送足够大的数据。(一个连接会设置MSS参数,因此,TCP/IP希望每次都能够以MSS尺寸的数据块来发送数据)。
* Nagle算法就是为了尽可能发送大块数据,避免网络中充斥着许多小数据块。
*/
bootstrap.option(ChannelOption.TCP_NODELAY, true);
bootstrap.handler(new ChannelInitializer<SocketChannel>() {
@Override