Skip to content

Commit 9fbfd70

Browse files
commit
1 parent c52a5c2 commit 9fbfd70

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
- CommandTimeout is set to 30 seconds by default (as NpgsqlCommand).
2-
31
## v0.15.3
42

53
- Added SeqNo to `Ydb.Sdk.Services.Topic.Reader.Message`.

src/Ydb.Sdk/src/Ado/YdbCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public override int CommandTimeout
106106
}
107107
}
108108

109-
private int _timeout = 30;
109+
private int _timeout;
110110

111111
public override CommandType CommandType { get; set; } = CommandType.Text;
112112
public override UpdateRowSource UpdatedRowSource { get; set; }

src/Ydb.Sdk/src/DriverConfig.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ public class DriverConfig
99
public string Database { get; }
1010
public ICredentialsProvider Credentials { get; }
1111

12+
public TimeSpan KeepAlivePingDelay { get; set; } = TimeSpan.FromSeconds(10);
13+
1214
internal X509Certificate2Collection CustomServerCertificates { get; } = new();
1315
internal TimeSpan EndpointDiscoveryInterval = TimeSpan.FromMinutes(1);
1416
internal TimeSpan EndpointDiscoveryTimeout = TimeSpan.FromSeconds(10);

src/Ydb.Sdk/src/Pool/ChannelPool.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@ internal class GrpcChannelFactory : IChannelFactory<GrpcChannel>
7777
{
7878
private readonly ILoggerFactory _loggerFactory;
7979
private readonly ILogger<GrpcChannelFactory> _logger;
80-
private readonly X509Certificate2Collection _x509Certificate2Collection;
80+
private readonly DriverConfig _config;
81+
82+
private X509Certificate2Collection ServerCertificates => _config.CustomServerCertificates;
8183

8284
internal GrpcChannelFactory(ILoggerFactory loggerFactory, DriverConfig config)
8385
{
8486
_loggerFactory = loggerFactory;
8587
_logger = loggerFactory.CreateLogger<GrpcChannelFactory>();
86-
_x509Certificate2Collection = config.CustomServerCertificates;
88+
_config = config;
8789
}
8890

8991
public GrpcChannel CreateChannel(string endpoint)
@@ -95,15 +97,18 @@ public GrpcChannel CreateChannel(string endpoint)
9597
LoggerFactory = _loggerFactory
9698
};
9799

98-
var httpHandler = new SocketsHttpHandler();
100+
var httpHandler = new SocketsHttpHandler
101+
{
102+
KeepAlivePingDelay = _config.KeepAlivePingDelay
103+
};
99104

100105
// https://github.com/grpc/grpc-dotnet/issues/2312#issuecomment-1790661801
101106
httpHandler.Properties["__GrpcLoadBalancingDisabled"] = true;
102107

103108
channelOptions.HttpHandler = httpHandler;
104109
channelOptions.DisposeHttpClient = true;
105110

106-
if (_x509Certificate2Collection.Count == 0)
111+
if (ServerCertificates.Count == 0)
107112
{
108113
return GrpcChannel.ForAddress(endpoint, channelOptions);
109114
}
@@ -124,11 +129,11 @@ public GrpcChannel CreateChannel(string endpoint)
124129
try
125130
{
126131
chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllowUnknownCertificateAuthority;
127-
chain.ChainPolicy.ExtraStore.AddRange(_x509Certificate2Collection);
132+
chain.ChainPolicy.ExtraStore.AddRange(ServerCertificates);
128133

129-
return chain.Build(new X509Certificate2(certificate)) && chain.ChainElements.Any(chainElement =>
130-
_x509Certificate2Collection.Any(trustedCert =>
131-
chainElement.Certificate.Thumbprint == trustedCert.Thumbprint));
134+
return chain.Build(new X509Certificate2(certificate))
135+
&& chain.ChainElements.Any(chainElement => ServerCertificates.Any(trustedCert =>
136+
chainElement.Certificate.Thumbprint == trustedCert.Thumbprint));
132137
}
133138
catch (Exception e)
134139
{

0 commit comments

Comments
 (0)