diff --git a/src/IO.Ably.Shared/ClientOptions.cs b/src/IO.Ably.Shared/ClientOptions.cs index 866ffa51d..41ebe1d49 100644 --- a/src/IO.Ably.Shared/ClientOptions.cs +++ b/src/IO.Ably.Shared/ClientOptions.cs @@ -226,7 +226,7 @@ public string[] GetFallbackHosts() { Logger.Warning("Deprecated fallbackHostsUseDefault : There is no longer a need to set this when the environment option is also set since the library will now generate the correct fallback hosts using the environment option."); } - + Logger.Warning("Deprecated fallbackHostsUseDefault : fallbackHosts: Ably.Defaults.FALLBACK_HOSTS"); return Defaults.FallbackHosts; } diff --git a/src/IO.Ably.Shared/Http/AblyHttpClient.cs b/src/IO.Ably.Shared/Http/AblyHttpClient.cs index 152ed762a..0facc0ef7 100644 --- a/src/IO.Ably.Shared/Http/AblyHttpClient.cs +++ b/src/IO.Ably.Shared/Http/AblyHttpClient.cs @@ -88,7 +88,7 @@ public async Task Execute(AblyRequest request) int currentTry = 0; var startTime = Now(); - var numberOfRetries = Options.HttpMaxRetryCount; // One for the first request + var maxNumberOfRetries = Options.HttpMaxRetryCount; // One for the first request var host = GetHost(); request.Headers.TryGetValue("request_id", out var requestId); @@ -115,8 +115,6 @@ public async Task Execute(AblyRequest request) if (response.CanRetry) { - currentTry++; - Logger.Warning(WrapWithRequestId("Failed response. " + response.GetFailedMessage() + ". Retrying...")); var (success, newHost) = HandleHostChangeForRetryableFailure(); if (success) @@ -124,6 +122,7 @@ public async Task Execute(AblyRequest request) Logger.Debug(WrapWithRequestId($"Retrying using host: {newHost}")); host = newHost; + currentTry++; continue; } } @@ -148,7 +147,7 @@ public async Task Execute(AblyRequest request) throw new AblyException(new ErrorInfo(WrapWithRequestId("Error executing request. " + ex.Message), ErrorCodes.InternalError), ex); } } - while (currentTry < numberOfRetries); + while (currentTry <= maxNumberOfRetries); throw new AblyException(new ErrorInfo(WrapWithRequestId("Error executing request, exceeded max no. of retries"), ErrorCodes.InternalError));