Commit 73f7f358 authored by Maodashu's avatar Maodashu

增加获取账号失败重连机制并限制重连次数

parent 0310a35e
...@@ -222,6 +222,7 @@ namespace OTWebSocket.API.Services ...@@ -222,6 +222,7 @@ namespace OTWebSocket.API.Services
private async Task<List<AccountInfo>> LoadAllAccount() private async Task<List<AccountInfo>> LoadAllAccount()
{ {
int delay = 5; int delay = 5;
int retry = 10;
_logger?.Debug($"[WebSocketService] 请求账号信息"); _logger?.Debug($"[WebSocketService] 请求账号信息");
List<AccountInfo> ret = null; List<AccountInfo> ret = null;
do do
...@@ -237,6 +238,8 @@ namespace OTWebSocket.API.Services ...@@ -237,6 +238,8 @@ namespace OTWebSocket.API.Services
_logger?.LogError($"[WebSocketService] 请求账号信息失败,稍候({delay}s)重连.....\n{e.Message}\n{e.StackTrace}"); _logger?.LogError($"[WebSocketService] 请求账号信息失败,稍候({delay}s)重连.....\n{e.Message}\n{e.StackTrace}");
} }
await Task.Delay(delay * 1000); await Task.Delay(delay * 1000);
retry--;
if (retry == 0) break;
} while (ret == null); } while (ret == null);
return ret; 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