diff --git a/packages/csharp/ArmoniK.Api.Client/Submitter/GrpcChannelFactory.cs b/packages/csharp/ArmoniK.Api.Client/Submitter/GrpcChannelFactory.cs index 0fc348da9..533225c0c 100644 --- a/packages/csharp/ArmoniK.Api.Client/Submitter/GrpcChannelFactory.cs +++ b/packages/csharp/ArmoniK.Api.Client/Submitter/GrpcChannelFactory.cs @@ -137,6 +137,8 @@ public static class GrpcChannelFactory /// Proxy configuration to use /// Type of the proxy used /// Which HttpMessageHandler type to use + /// TCP KeepAlive time + /// TCP KeepAlive time interval /// Optional logger /// HttpMessageHandler private static HttpMessageHandler CreateHttpMessageHandler(bool https, @@ -146,6 +148,8 @@ private static HttpMessageHandler CreateHttpMessageHandler(bool htt IWebProxy? proxy, ProxyType proxyType, HandlerType handlerType, + TimeSpan keepAliveTime, + TimeSpan keepAliveTimeInterval, ILogger? logger = null) { Func? validationCallback = null; @@ -199,6 +203,15 @@ private static HttpMessageHandler CreateHttpMessageHandler(bool htt } var winHandler = new WinHttpHandler(); + try + { + winHandler.TcpKeepAliveEnabled = true; + winHandler.TcpKeepAliveTime = keepAliveTime; + winHandler.TcpKeepAliveInterval = keepAliveTimeInterval; + } + catch (NotSupportedException) + { + } if (https) { @@ -387,6 +400,8 @@ private static GrpcChannel CreateChannelInternal(GrpcClient optionsGrpcClient, proxy, proxyType, handlerType, + optionsGrpcClient.KeepAliveTime, + optionsGrpcClient.KeepAliveTimeInterval, logger); // Warn that RequestTimeout is not supported.