Add plus retry at ttlexpired
MODIFY
MagicalCryptoWallet/TorSocks5/TorHttpClient.cs
MagicalCryptoWallet/TorSocks5/TorHttpClient.cs
using MagicalCryptoWallet.Helpers;
using MagicalCryptoWallet.Http.Models;
using MagicalCryptoWallet.Logging;
+using MagicalCryptoWallet.TorSocks5.Models.Fields.OctetFields;
using Nito.AsyncEx;
using System;
using System.Collections.Generic;
@@ -73,7 +74,19 @@ namespace MagicalCryptoWallet.TorSocks5
}
catch (Exception ex)
{
- Logger.LogDebug<TorHttpClient>(ex);
+ Logger.LogTrace<TorHttpClient>(ex);
+
+ TorSocks5Client?.Dispose(); // rebuild the connection and retry
+ TorSocks5Client = null;
+
+ try
+ {
+ return await SendAsync(request);
+ }
+ // If we get ttlexpired then retry again linux sometimes do this.
+ catch (TorSocks5FailureResponseException ex2) when (ex2.RepField == RepField.TtlExpired)
+ {
+ Logger.LogTrace<TorHttpClient>(ex);
TorSocks5Client?.Dispose(); // rebuild the connection and retry
TorSocks5Client = null;
@@ -82,6 +95,7 @@ namespace MagicalCryptoWallet.TorSocks5
}
}
}
+ }
private async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request)
{

Add plus retry at ttlexpired