From 5f9efa3bb0e62fe6708c3acc455626c452d43b69 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Wed, 12 Mar 2025 10:27:06 +0100 Subject: [PATCH] =?UTF-8?q?refactor(AuthClient):=20Ausf=C3=BChrlichere=20P?= =?UTF-8?q?rotokollierung=20hinzuf=C3=BCgen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DigitalData.Auth.Client/AuthClient.cs | 9 ++++++++- DigitalData.Auth.Client/DigitalData.Auth.Client.csproj | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/DigitalData.Auth.Client/AuthClient.cs b/DigitalData.Auth.Client/AuthClient.cs index 4601509..3e4f95f 100644 --- a/DigitalData.Auth.Client/AuthClient.cs +++ b/DigitalData.Auth.Client/AuthClient.cs @@ -51,16 +51,23 @@ public class AuthClient : IAuthClient, IHostedService await GetAllPublicKeysAsync(); } + private int nOfAttempts = 0; + private async Task TryStartConnectionAsync(CancellationToken cancellationToken = default) { try { + nOfAttempts += 1; await _connection.StartAsync(cancellationToken); + _logger?.LogInformation("Auth-client connection successful. Number of connection attempts {nOfAttempts}.", nOfAttempts); return true; } catch(HttpRequestException ex) { - _logger?.LogError(ex, "Connection is failed. {message}", ex.Message); + if (_params.RetryDelay is null) + _logger?.LogError(ex, "Auth-client connection failed. {message}", ex.Message); + else + _logger?.LogError(ex, "Auth-client connection failed and will be retried every {time} seconds. The status of being successful can be followed from the information logs.\n{message}", _params.RetryDelay.Value.TotalSeconds, ex.Message); return false; } } diff --git a/DigitalData.Auth.Client/DigitalData.Auth.Client.csproj b/DigitalData.Auth.Client/DigitalData.Auth.Client.csproj index e21aaa0..e5a6f22 100644 --- a/DigitalData.Auth.Client/DigitalData.Auth.Client.csproj +++ b/DigitalData.Auth.Client/DigitalData.Auth.Client.csproj @@ -5,7 +5,7 @@ enable enable DigitalData.Auth.Client - 1.2.1.1 + 1.3.1 DigitalData.Auth.Client is a SignalR-based authentication client that enables applications to connect to a central authentication hub for real-time message exchange. It provides seamless connection management, automatic reconnection (RetryPolicy), and event-driven communication (ClientEvents). The package includes dependency injection support via DIExtensions, allowing easy integration into ASP.NET Core applications. With built-in retry policies and secure message handling, it ensures a reliable and scalable authentication client for real-time authentication workflows. Digital Data GmbH Digital Data GmbH @@ -14,8 +14,8 @@ auth_icon.png http://git.dd:3000/AppStd/DigitalData.Auth Digital Data Auth Authorization Authentication - 1.2.1.1 - 1.2.1.1 + 1.3.1 + 1.3.1