diff --git a/BTCPayServer/HostedServices/InvoiceNotificationManager.cs b/BTCPayServer/HostedServices/InvoiceNotificationManager.cs index c0a78ae3a..4e3fa6e4a 100644 --- a/BTCPayServer/HostedServices/InvoiceNotificationManager.cs +++ b/BTCPayServer/HostedServices/InvoiceNotificationManager.cs @@ -24,7 +24,7 @@ namespace BTCPayServer.HostedServices { public class InvoiceNotificationManager : IHostedService { - public static HttpClient _Client = new HttpClient(); + HttpClient _Client; public class ScheduledJob { @@ -46,6 +46,7 @@ namespace BTCPayServer.HostedServices private readonly EmailSenderFactory _EmailSenderFactory; public InvoiceNotificationManager( + IHttpClientFactory httpClientFactory, IBackgroundJobClient jobClient, EventAggregator eventAggregator, InvoiceRepository invoiceRepository, @@ -53,6 +54,7 @@ namespace BTCPayServer.HostedServices ILogger logger, EmailSenderFactory emailSenderFactory) { + _Client = httpClientFactory.CreateClient(); _JobClient = jobClient; _EventAggregator = eventAggregator; _InvoiceRepository = invoiceRepository;