客户端重连优化.

This commit is contained in:
aoshiguchen
2023-06-02 21:20:19 +08:00
parent e2195ab966
commit 8c2e1b8f6c
3 changed files with 10 additions and 9 deletions
@@ -49,7 +49,7 @@ public class ProxyClientService {
/**
* 重连间隔(秒)
*/
private static final long RECONNECT_INTERVAL_SECONDS = 8;
private static final long RECONNECT_INTERVAL_SECONDS = 5;
/**
* 重连次数
*/
@@ -80,7 +80,7 @@ public class ProxyClientService {
bootstrap.group(workerGroup);
bootstrap.channel(NioSocketChannel.class);
bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000);
bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 3000);
bootstrap.option(ChannelOption.SO_KEEPALIVE, true);
/**
* TCP/IP协议中,无论发送多少数据,总是要在数据前面加上协议头,同时,对方接收到数据,也需要发送ACK表示确认。为了尽可能的利用网络带宽,TCP总是希望尽可能的发送足够大的数据。(一个连接会设置MSS参数,因此,TCP/IP希望每次都能够以MSS尺寸的数据块来发送数据)。
@@ -189,12 +189,13 @@ public class ProxyClientService {
}
protected synchronized void reconnect() {
if (!reconnectServiceEnable) {
if (!reconnectServiceEnable || null == channel) {
return;
}
if (null != channel && channel.isActive()) {
if (channel.isActive()) {
return;
}
channel.close();
log.info("客户端重连 seq:{}", ++reconnectCount);
try {
connectProxyServer();
@@ -9,9 +9,9 @@ neutrino:
length-field-length: 4
initial-bytes-to-strip: 0
length-adjustment: 0
read-idle-time: 40
write-idle-time: 5
all-idle-time-seconds: 45
read-idle-time: 8
write-idle-time: 3
all-idle-time-seconds: 8
client:
thread-count: 50
key-store-password: ${STORE_PASS:123456}
@@ -20,4 +20,4 @@ neutrino:
server-port: ${SERVER_PORT:9002}
ssl-enable: ${SSL_ENABLE:true}
obtain-license-interval: 5
license-key: ${LICENSE_KEY:b0a907332b474b25897c4dcb31fc7eb6}
license-key: ${LICENSE_KEY:}
@@ -9,7 +9,7 @@ neutrino:
length-field-length: 4
initial-bytes-to-strip: 0
length-adjustment: 0
read-idle-time: 40
read-idle-time: 30
write-idle-time: 5
all-idle-time-seconds: 0
tunnel: