diff --git a/Inspectron.Epson/PrintServer/JobSources/SignalRPrintJobSource.cs b/Inspectron.Epson/PrintServer/JobSources/SignalRPrintJobSource.cs index 8b9a903..7a701c3 100644 --- a/Inspectron.Epson/PrintServer/JobSources/SignalRPrintJobSource.cs +++ b/Inspectron.Epson/PrintServer/JobSources/SignalRPrintJobSource.cs @@ -38,15 +38,20 @@ public class SignalRPrintJobSource: IPrintJobSource private async Task InitializeConnectionAsync() { - try + while (true) { - await _connection.StartAsync(); - await _connection.InvokeAsync("JoinGroup", _groupConfiguration.RestaurantId); - _logger.LogInformation("SignalR connection started and joined group {GroupId}.", _groupConfiguration.RestaurantId); - } - catch (Exception ex) - { - _logger.LogError(ex, "Failed to initialize SignalR connection."); + try + { + await _connection.StartAsync(); + await _connection.InvokeAsync("JoinGroup", _groupConfiguration.RestaurantId); + _logger.LogInformation("SignalR connection started and joined group {GroupId}.", _groupConfiguration.RestaurantId); + return; + } + catch (Exception ex) + { + _logger.LogError(ex, "Failed to initialize SignalR connection. Retrying in 5 seconds..."); + await Task.Delay(5000); + } } }