增加配置文件ksec参数 reconnectNum#重连次数 默认10次-1永远重连,reconnectInterval#重连间隔 默认10s

hongrunHaotian
LAPTOP-S9HJSOEB\昊天 3 years ago
parent 97b9db9d19
commit 1c3ea016e6

@ -82,6 +82,8 @@ public class ConfigProperties {
public static class KSEC{
private String ip;
private Integer port;
private Integer reconnectNum = 10;
private Integer reconnectInterval = 10;
}
@Data

@ -25,10 +25,6 @@ public class KsecNettyClient {
@Resource
private ConfigProperties configProperties;
/**
*
*/
private static int RECONNECT_NUM = 10;
private static Channel channel;
@ -68,13 +64,22 @@ public class KsecNettyClient {
} catch (InterruptedException e) {
e.printStackTrace();
}
while (num < RECONNECT_NUM && !isConnected) {
/**
*
*/
while ((ksec.getReconnectNum() == -1 || num < ksec.getReconnectNum() ) && !isConnected) {
try {
createClient(ksec);
} catch (Exception e) {
//没连上 继续
log.error("reconnect error num:{}", num);
num++;
try {
Thread.sleep(configProperties.getKsec().getReconnectNum()*1000);
} catch (InterruptedException ex) {
throw new RuntimeException(ex);
}
continue;
}
isConnected = true;

@ -7,7 +7,7 @@ spring:
maxWait: 60000
minEvictableIdleTimeMillis: 300000
minIdle: 15
password: Leaper@123
password: root
poolPreparedStatements: true
testOnBorrow: true
testOnReturn: false
@ -48,6 +48,10 @@ serverMode: 1
ksec:
ip: 127.0.0.1
port: 3000
#重连次数 默认10次
reconnectNum: 5
#重连间隔 默认10s
reconnectInterval: 10
# ------------ 实时视频流 全部页面的格式 行列数量
videoStyleConfig:
videoStyleRow: 2

Loading…
Cancel
Save