Commit 0310a35e authored by Maodashu's avatar Maodashu

增加获取账号失败重连机制

parent 86b8c97f
......@@ -221,9 +221,23 @@ namespace OTWebSocket.API.Services
private async Task<List<AccountInfo>> LoadAllAccount()
{
int delay = 5;
_logger?.Debug($"[WebSocketService] 请求账号信息");
List<AccountInfo> ret = await _apiService.GetKeyList();
_logger?.Debug($"[WebSocketService] 请求账号信息完毕,合计 {ret.Count} 个账号");
List<AccountInfo> ret = null;
do
{
try
{
ret = await _apiService.GetKeyList();
_logger?.Debug($"[WebSocketService] 请求账号信息完毕,合计 {ret.Count} 个账号");
break;
}
catch (Exception e)
{
_logger?.LogError($"[WebSocketService] 请求账号信息失败,稍候({delay}s)重连.....\n{e.Message}\n{e.StackTrace}");
}
await Task.Delay(delay * 1000);
} while (ret == null);
return ret;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment