refactor: save current workspace state including FinlyticAnalyzer fixes, FinlyticApp trade route alignment, and DTO audit documentation
This commit is contained in:
@@ -43,6 +43,8 @@ namespace FinlyticCore.Util;
|
||||
[JsonSerializable(typeof(List<AssetFundamentalsDto>))]
|
||||
[JsonSerializable(typeof(CorporateEventDto))]
|
||||
[JsonSerializable(typeof(List<CorporateEventDto>))]
|
||||
[JsonSerializable(typeof(CalendarEventResponseDto))]
|
||||
[JsonSerializable(typeof(List<CalendarEventResponseDto>))]
|
||||
[JsonSerializable(typeof(IsinSentimentSummaryDto))]
|
||||
[JsonSerializable(typeof(IsinAnalysisEntry))]
|
||||
[JsonSerializable(typeof(SectorSentimentSummaryDto))]
|
||||
@@ -72,6 +74,7 @@ namespace FinlyticCore.Util;
|
||||
[JsonSerializable(typeof(ArticleRequest))]
|
||||
[JsonSerializable(typeof(AnalyzeSentimentRequest))]
|
||||
[JsonSerializable(typeof(EmptyRequest))]
|
||||
[JsonSerializable(typeof(GetEventsByMonthRequest))]
|
||||
[JsonSerializable(typeof(ManualAnalysisRpcRequest))]
|
||||
|
||||
[JsonSerializable(typeof(ServiceHealthResponse))]
|
||||
|
||||
@@ -281,24 +281,33 @@ public abstract class ManagedMqttClient : IDisposable
|
||||
if (_cts == null || _cts.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
_logger.LogWarning("Lost connection to MQTT broker (Reason: {Reason}). Initiating auto-reconnect loop in 5 seconds...", e.Reason);
|
||||
_logger.LogWarning("Lost connection to MQTT broker (Reason: {Reason}). Initiating auto-reconnect loop...", e.Reason);
|
||||
|
||||
try
|
||||
int attempt = 0;
|
||||
while (_cts != null && !_cts.IsCancellationRequested)
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(5), _cts.Token);
|
||||
|
||||
await _mqttClient.ReconnectAsync(_cts.Token);
|
||||
|
||||
if (_mqttClient.IsConnected)
|
||||
attempt++;
|
||||
var delaySeconds = Math.Min(5 * Math.Pow(2, attempt - 1), 60); // 5s, 10s, 20s, 40s, 60s max
|
||||
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("MQTT client reconnected successfully.");
|
||||
await OnConnectedAsync();
|
||||
_logger.LogInformation("Reconnect attempt {Attempt} in {Delay}s...", attempt, delaySeconds);
|
||||
await Task.Delay(TimeSpan.FromSeconds(delaySeconds), _cts.Token);
|
||||
|
||||
await _mqttClient.ReconnectAsync(_cts.Token);
|
||||
|
||||
if (_mqttClient.IsConnected)
|
||||
{
|
||||
_logger.LogInformation("MQTT client reconnected successfully after {Attempt} attempt(s).", attempt);
|
||||
await OnConnectedAsync();
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException) { return; /* Expected on application shutdown */ }
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Reconnect attempt {Attempt} to the MQTT broker failed.", attempt);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException) { /* Expected swallow on application shutdown */ }
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Reconnection attempt to the MQTT broker failed.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user