From f660b5119cfda55c4c793c29cae68953bb7e96b1 Mon Sep 17 00:00:00 2001 From: EugeneTes Date: Mon, 2 Feb 2026 15:40:24 +0100 Subject: [PATCH] signalR retry on initial connection failure --- .../JobSources/SignalRPrintJobSource.cs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) 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); + } } }