Put try-catch statement when trying to connect to the queue for the first time

This commit is contained in:
Noe 2023-11-06 14:29:04 +01:00
parent 30a3a05de0
commit 511c3080a6
1 changed files with 15 additions and 8 deletions

View File

@ -297,6 +297,8 @@ internal static class Program
}
private static void SubscribeToQueue(SalimaxAlarmState currentSalimaxState, String? s3Bucket)
{
try
{
_factory = new ConnectionFactory { HostName = VpnServerIp };
_connection = _factory.CreateConnection();
@ -307,6 +309,11 @@ internal static class Program
_subscribedToQueue = true;
}
catch (Exception ex)
{
Console.WriteLine("An error occurred while connecting to the RabbitMQ queue: " + ex.Message);
}
}
private static IPAddress FindVpnIp()
{