mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 22:25:28 +01:00
make sure to not crash whole process if nbxplorer unavailable
This commit is contained in:
parent
1cda0eff16
commit
e3a0122eb3
2 changed files with 20 additions and 16 deletions
|
@ -41,7 +41,7 @@ services:
|
|||
# - eclair2
|
||||
|
||||
nbxplorer:
|
||||
image: nicolasdorier/nbxplorer:1.0.0.37
|
||||
image: nicolasdorier/nbxplorer:1.0.0.39
|
||||
ports:
|
||||
- "32838:32838"
|
||||
expose:
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace BTCPayServer.HostedServices
|
|||
{
|
||||
foreach (var nbxplorerState in _Dashboards.GetAll())
|
||||
{
|
||||
if(nbxplorerState.Status != null && nbxplorerState.Status.IsFullySynched)
|
||||
if (nbxplorerState.Status != null && nbxplorerState.Status.IsFullySynched)
|
||||
{
|
||||
await Listen(nbxplorerState.Network);
|
||||
}
|
||||
|
@ -102,22 +102,22 @@ namespace BTCPayServer.HostedServices
|
|||
|
||||
private async Task Listen(BTCPayNetwork network)
|
||||
{
|
||||
if (_Sessions.ContainsKey(network.CryptoCode))
|
||||
return;
|
||||
var client = _ExplorerClients.GetExplorerClient(network);
|
||||
if (client == null)
|
||||
return;
|
||||
if (_Cts.IsCancellationRequested)
|
||||
return;
|
||||
var session = await client.CreateNotificationSessionAsync(_Cts.Token).ConfigureAwait(false);
|
||||
if (!_Sessions.TryAdd(network.CryptoCode, session))
|
||||
{
|
||||
await session.DisposeAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (_Sessions.ContainsKey(network.CryptoCode))
|
||||
return;
|
||||
var client = _ExplorerClients.GetExplorerClient(network);
|
||||
if (client == null)
|
||||
return;
|
||||
if (_Cts.IsCancellationRequested)
|
||||
return;
|
||||
var session = await client.CreateNotificationSessionAsync(_Cts.Token).ConfigureAwait(false);
|
||||
if (!_Sessions.TryAdd(network.CryptoCode, session))
|
||||
{
|
||||
await session.DisposeAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
using (session)
|
||||
{
|
||||
await session.ListenNewBlockAsync(_Cts.Token).ConfigureAwait(false);
|
||||
|
@ -149,6 +149,10 @@ namespace BTCPayServer.HostedServices
|
|||
}
|
||||
}
|
||||
catch when (_Cts.IsCancellationRequested) { }
|
||||
catch(Exception ex)
|
||||
{
|
||||
Logs.PayServer.LogError(ex, $"Error while connecting to WebSocket of NBXplorer ({network.CryptoCode})");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Logs.PayServer.LogInformation($"Disconnected from WebSocket of NBXplorer ({network.CryptoCode})");
|
||||
|
|
Loading…
Add table
Reference in a new issue