From e044c223f0e87aafb4d0297c22eb3e0000258d69 Mon Sep 17 00:00:00 2001 From: sacOO7 Date: Fri, 19 Apr 2024 11:10:50 +0530 Subject: [PATCH] Refactored code that checks for default hosts when retrying fallbacks --- src/IO.Ably.Shared/ClientOptions.cs | 4 ---- src/IO.Ably.Shared/Realtime/AttemptsHelpers.cs | 9 +-------- src/IO.Ably.Tests.Shared/Rest/RestSpecs.cs | 2 +- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/IO.Ably.Shared/ClientOptions.cs b/src/IO.Ably.Shared/ClientOptions.cs index 41ebe1d49..ed3a546d5 100644 --- a/src/IO.Ably.Shared/ClientOptions.cs +++ b/src/IO.Ably.Shared/ClientOptions.cs @@ -147,10 +147,6 @@ public string[] FallbackHosts internal bool IsProductionEnvironment => Environment.IsEmpty() || Environment.Equals("production", StringComparison.OrdinalIgnoreCase); - internal bool IsDefaultRestHost => FullRestHost() == Defaults.RestHost; - - internal bool IsDefaultRealtimeHost => FullRealtimeHost() == Defaults.RealtimeHost; - internal bool IsDefaultPort => Tls ? TlsPort == Defaults.TlsPort : Port == Defaults.Port; /// diff --git a/src/IO.Ably.Shared/Realtime/AttemptsHelpers.cs b/src/IO.Ably.Shared/Realtime/AttemptsHelpers.cs index 247dff8d6..586441c8a 100644 --- a/src/IO.Ably.Shared/Realtime/AttemptsHelpers.cs +++ b/src/IO.Ably.Shared/Realtime/AttemptsHelpers.cs @@ -9,14 +9,7 @@ internal static class AttemptsHelpers { public static async Task CanFallback(this AblyRest restClient, ErrorInfo error) { - return IsDefaultHost() && - error != null && error.IsRetryableStatusCode() && - await restClient.CanConnectToAbly(); - - bool IsDefaultHost() - { - return restClient.Options.IsDefaultRealtimeHost; - } + return error != null && error.IsRetryableStatusCode() && await restClient.CanConnectToAbly(); } public static bool ShouldSuspend(this RealtimeState state, Func now = null) diff --git a/src/IO.Ably.Tests.Shared/Rest/RestSpecs.cs b/src/IO.Ably.Tests.Shared/Rest/RestSpecs.cs index 4045685b7..1805e7d46 100644 --- a/src/IO.Ably.Tests.Shared/Rest/RestSpecs.cs +++ b/src/IO.Ably.Tests.Shared/Rest/RestSpecs.cs @@ -607,7 +607,7 @@ public async Task ShouldUseCustomFallbackHostIfProvided() [Fact] [Trait("spec", "RSC15a")] [Trait("spec", "TO3k6")] - public async Task ShouldUseCustomFallbackHostIfProvidedAndDefaultHostIsDifferent() + public async Task ShouldUseProvidedCustomFallbackHostWhenDefaultHostIsDifferent() { _response.StatusCode = HttpStatusCode.BadGateway; var attemptedList = new List();