| 40 | } |
| 41 | |
| 42 | func (cfg *Engine) WtRemote(ctx context.Context) { |
| 43 | retryDelay := [...]int{2, 3, 5, 8, 13} |
| 44 | for i := 0; ctx.Err() == nil; i++ { |
| 45 | connected, err := cfg.Remote(ctx) |
| 46 | if err == nil { |
| 47 | //不需要重试了,服务器返回了错误 |
| 48 | return |
| 49 | } |
| 50 | if Global.LogLang == "zh" { |
| 51 | log.Error("连接到控制台服务器", cfg.Server, "失败", err) |
| 52 | } else { |
| 53 | log.Error("connect to console server ", cfg.Server, " ", err) |
| 54 | } |
| 55 | if connected { |
| 56 | i = 0 |
| 57 | } else if i >= 5 { |
| 58 | i = 4 |
| 59 | } |
| 60 | time.Sleep(time.Second * time.Duration(retryDelay[i])) |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | func (cfg *Engine) Remote(ctx context.Context) (wasConnected bool, err error) { |
| 65 | tlsConf := &tls.Config{ |