refactor(AuthClient): Ausführlichere Protokollierung hinzufügen.

This commit is contained in:
Developer 02 2025-03-12 10:27:06 +01:00
parent d46dbbb877
commit 5f9efa3bb0
2 changed files with 11 additions and 4 deletions

View File

@ -51,16 +51,23 @@ public class AuthClient : IAuthClient, IHostedService
await GetAllPublicKeysAsync(); await GetAllPublicKeysAsync();
} }
private int nOfAttempts = 0;
private async Task<bool> TryStartConnectionAsync(CancellationToken cancellationToken = default) private async Task<bool> TryStartConnectionAsync(CancellationToken cancellationToken = default)
{ {
try try
{ {
nOfAttempts += 1;
await _connection.StartAsync(cancellationToken); await _connection.StartAsync(cancellationToken);
_logger?.LogInformation("Auth-client connection successful. Number of connection attempts {nOfAttempts}.", nOfAttempts);
return true; return true;
} }
catch(HttpRequestException ex) 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; return false;
} }
} }

View File

@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<PackageId>DigitalData.Auth.Client</PackageId> <PackageId>DigitalData.Auth.Client</PackageId>
<Version>1.2.1.1</Version> <Version>1.3.1</Version>
<Description>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.</Description> <Description>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.</Description>
<Company>Digital Data GmbH</Company> <Company>Digital Data GmbH</Company>
<Product>Digital Data GmbH</Product> <Product>Digital Data GmbH</Product>
@ -14,8 +14,8 @@
<PackageIcon>auth_icon.png</PackageIcon> <PackageIcon>auth_icon.png</PackageIcon>
<RepositoryUrl>http://git.dd:3000/AppStd/DigitalData.Auth</RepositoryUrl> <RepositoryUrl>http://git.dd:3000/AppStd/DigitalData.Auth</RepositoryUrl>
<PackageTags>Digital Data Auth Authorization Authentication</PackageTags> <PackageTags>Digital Data Auth Authorization Authentication</PackageTags>
<AssemblyVersion>1.2.1.1</AssemblyVersion> <AssemblyVersion>1.3.1</AssemblyVersion>
<FileVersion>1.2.1.1</FileVersion> <FileVersion>1.3.1</FileVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>