refactor(AuthClient): Detaillierte Protokollierung für AuthClient hinzugefügt.
This commit is contained in:
parent
5f9efa3bb0
commit
031f830b8f
@ -28,7 +28,19 @@ public class AuthClient : IAuthClient, IHostedService
|
|||||||
|
|
||||||
_connection.On<string, string, string>(nameof(ReceivePublicKeyAsync), ReceivePublicKeyAsync);
|
_connection.On<string, string, string>(nameof(ReceivePublicKeyAsync), ReceivePublicKeyAsync);
|
||||||
|
|
||||||
_connection.Reconnected += async cnnId => await GetAllPublicKeysAsync();
|
_connection.Reconnected += async cnnId =>
|
||||||
|
{
|
||||||
|
_logger?.LogInformation("Auth-client reconnected. Number of connection attempts {nOfAttempts}.", _nOfAttempts);
|
||||||
|
await GetAllPublicKeysAsync();
|
||||||
|
_nOfAttempts = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
_connection.Reconnecting += (ex) =>
|
||||||
|
{
|
||||||
|
logger?.LogError(ex, "Auth-client disconnected. Attempt to reconnect every {time} seconds.", _params.RetryDelay!.Value.TotalSeconds);
|
||||||
|
_nOfAttempts += 1;
|
||||||
|
return Task.CompletedTask;
|
||||||
|
};
|
||||||
|
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
@ -51,23 +63,27 @@ public class AuthClient : IAuthClient, IHostedService
|
|||||||
await GetAllPublicKeysAsync();
|
await GetAllPublicKeysAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int nOfAttempts = 0;
|
private int _nOfAttempts = 0;
|
||||||
|
|
||||||
private async Task<bool> TryStartConnectionAsync(CancellationToken cancellationToken = default)
|
private async Task<bool> TryStartConnectionAsync(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
nOfAttempts += 1;
|
_nOfAttempts += 1;
|
||||||
await _connection.StartAsync(cancellationToken);
|
await _connection.StartAsync(cancellationToken);
|
||||||
_logger?.LogInformation("Auth-client connection successful. Number of connection attempts {nOfAttempts}.", nOfAttempts);
|
_logger?.LogInformation("Auth-client connection successful. Number of connection attempts {nOfAttempts}.", _nOfAttempts);
|
||||||
|
_nOfAttempts = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch(HttpRequestException ex)
|
catch(HttpRequestException ex)
|
||||||
{
|
{
|
||||||
if (_params.RetryDelay is null)
|
if(_nOfAttempts < 2)
|
||||||
_logger?.LogError(ex, "Auth-client connection failed. {message}", ex.Message);
|
{
|
||||||
else
|
if (_params.RetryDelay is null)
|
||||||
_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);
|
_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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.3.1</Version>
|
<Version>1.3.2</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.3.1</AssemblyVersion>
|
<AssemblyVersion>1.3.2</AssemblyVersion>
|
||||||
<FileVersion>1.3.1</FileVersion>
|
<FileVersion>1.3.2</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user