signalR retry on initial connection failure
This commit is contained in:
@@ -38,15 +38,20 @@ public class SignalRPrintJobSource: IPrintJobSource
|
|||||||
|
|
||||||
private async Task InitializeConnectionAsync()
|
private async Task InitializeConnectionAsync()
|
||||||
{
|
{
|
||||||
try
|
while (true)
|
||||||
{
|
{
|
||||||
await _connection.StartAsync();
|
try
|
||||||
await _connection.InvokeAsync("JoinGroup", _groupConfiguration.RestaurantId);
|
{
|
||||||
_logger.LogInformation("SignalR connection started and joined group {GroupId}.", _groupConfiguration.RestaurantId);
|
await _connection.StartAsync();
|
||||||
}
|
await _connection.InvokeAsync("JoinGroup", _groupConfiguration.RestaurantId);
|
||||||
catch (Exception ex)
|
_logger.LogInformation("SignalR connection started and joined group {GroupId}.", _groupConfiguration.RestaurantId);
|
||||||
{
|
return;
|
||||||
_logger.LogError(ex, "Failed to initialize SignalR connection.");
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Failed to initialize SignalR connection. Retrying in 5 seconds...");
|
||||||
|
await Task.Delay(5000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user