From 2a302ea3460c5dfed3957bc21e0e8fa2e8d6ba6a Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Wed, 20 Mar 2019 14:35:33 +0900 Subject: [PATCH] Do not spam logs if we can't connect to lightning because lightning is not started --- .../Payments/Lightning/LightningListener.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/BTCPayServer/Payments/Lightning/LightningListener.cs b/BTCPayServer/Payments/Lightning/LightningListener.cs index 8ce837321..bfcd93b53 100644 --- a/BTCPayServer/Payments/Lightning/LightningListener.cs +++ b/BTCPayServer/Payments/Lightning/LightningListener.cs @@ -100,13 +100,25 @@ namespace BTCPayServer.Payments.Lightning { var charge = lightningSupportedMethod.CreateClient(network); LightningInvoice chargeInvoice = null; + string errorMessage = $"{lightningSupportedMethod.CryptoCode} (Lightning): Can't connect to the lightning server"; try { chargeInvoice = await charge.GetInvoice(lightningMethod.InvoiceId); } + catch (System.Net.Sockets.SocketException socketEx) when (socketEx.SocketErrorCode == System.Net.Sockets.SocketError.ConnectionRefused) + { + Logs.PayServer.LogError(errorMessage); + continue; + } + catch (Exception ex) when (ex.InnerException is System.Net.Sockets.SocketException socketEx + && socketEx.SocketErrorCode == System.Net.Sockets.SocketError.ConnectionRefused) + { + Logs.PayServer.LogError(errorMessage); + continue; + } catch (Exception ex) { - Logs.PayServer.LogError(ex, $"{lightningSupportedMethod.CryptoCode} (Lightning): Can't connect to the lightning server"); + Logs.PayServer.LogError(ex, errorMessage); continue; } if (chargeInvoice == null)