From da872f10e7f7578dd5bb28e10cb73c4b8ebbcc07 Mon Sep 17 00:00:00 2001 From: vnugent Date: Sat, 20 Apr 2024 12:01:08 -0400 Subject: chore: Package update & add http error handler --- .../src/VNLib.Data.Caching.Providers.Redis.csproj | 2 +- .../src/FBMCacheClient.cs | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'plugins') diff --git a/plugins/VNLib.Data.Caching.Providers.Redis/src/VNLib.Data.Caching.Providers.Redis.csproj b/plugins/VNLib.Data.Caching.Providers.Redis/src/VNLib.Data.Caching.Providers.Redis.csproj index ac5fb63..a896cf8 100644 --- a/plugins/VNLib.Data.Caching.Providers.Redis/src/VNLib.Data.Caching.Providers.Redis.csproj +++ b/plugins/VNLib.Data.Caching.Providers.Redis/src/VNLib.Data.Caching.Providers.Redis.csproj @@ -39,7 +39,7 @@ - + diff --git a/plugins/VNLib.Data.Caching.Providers.VNCache/src/FBMCacheClient.cs b/plugins/VNLib.Data.Caching.Providers.VNCache/src/FBMCacheClient.cs index e84a077..28ccdcd 100644 --- a/plugins/VNLib.Data.Caching.Providers.VNCache/src/FBMCacheClient.cs +++ b/plugins/VNLib.Data.Caching.Providers.VNCache/src/FBMCacheClient.cs @@ -23,6 +23,7 @@ */ using System; +using System.IO; using System.Net.Http; using System.Threading; using System.Threading.Tasks; @@ -255,21 +256,22 @@ namespace VNLib.Data.Caching.Providers.VNCache pluginLog.Verbose("Stack trace: {re}", wse); } //SEs may be raised when the server is not available - catch (HttpRequestException he) when (he.InnerException is SocketException) + catch (HttpRequestException he) when (he.InnerException is SocketException se) { pluginLog.Debug("Failed to connect to random cache server because a TCP connection could not be established"); - pluginLog.Verbose("Stack trace: {re}", he.InnerException); + pluginLog.Verbose("Stack trace: {re}", se); + await Task.Delay(1000, exitToken); } - catch (HttpRequestException he) when (he.StatusCode.HasValue) + catch (HttpRequestException he) when (he.InnerException is IOException ioe && ioe.InnerException is SocketException se) { - pluginLog.Warn("Failed to negotiate with cache server {reason}", he.Message); - pluginLog.Verbose("Stack trace: {re}", he); + pluginLog.Debug("Failed to connect to random cache server because a TCP connection could not be established"); + pluginLog.Verbose("Stack trace: {re}", se); await Task.Delay(1000, exitToken); } - catch(HttpRequestException hre) when (hre.InnerException is SocketException se) + catch (HttpRequestException he) when (he.StatusCode.HasValue) { - pluginLog.Warn("Failed to establish a TCP connection to server {server} {reason}", node.NodeId, se.Message); - pluginLog.Verbose("Stack trace: {re}", se); + pluginLog.Warn("Failed to negotiate with cache server {reason}", he.Message); + pluginLog.Verbose("Stack trace: {re}", he); await Task.Delay(1000, exitToken); } finally -- cgit