|
|
|
@ -156,13 +156,21 @@ func ConnectToServer() {
|
|
|
|
|
log.Error("ConnectToServer:", r)
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
secondaryAddr := Common.LoadConfig().SeverData.BackUpServerIP + ":" + strconv.Itoa(ServerPort)
|
|
|
|
|
|
|
|
|
|
for {
|
|
|
|
|
c, err := net.Dial("tcp", Common.LoadConfig().SeverData.ServerIP+":"+strconv.Itoa(ServerPort))
|
|
|
|
|
if err != nil {
|
|
|
|
|
holmes.Errorf("连接失败,%v 后重试... 错误: %v\n", reconnectInterval, err)
|
|
|
|
|
time.Sleep(reconnectInterval)
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
// 主IP失败时尝试备选IP
|
|
|
|
|
c, err = net.Dial("tcp", secondaryAddr)
|
|
|
|
|
if err != nil {
|
|
|
|
|
holmes.Errorf("备选IP连接失败,%v 后重试主IP... 错误: %v\n", reconnectInterval, err)
|
|
|
|
|
time.Sleep(reconnectInterval)
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onConnect := tao.OnConnectOption(func(conn tao.WriteCloser) bool {
|
|
|
|
|