@@ -29,6 +29,7 @@ private void InitDefaultValues()
2929 _database = "/local" ;
3030 _maxSessionPool = 100 ;
3131 _useTls = false ;
32+ _connectTimeout = GrpcDefaultSettings . ConnectTimeoutSeconds ;
3233 _keepAlivePingDelay = GrpcDefaultSettings . DefaultKeepAlivePingSeconds ;
3334 _keepAlivePingTimeout = GrpcDefaultSettings . DefaultKeepAlivePingTimeoutSeconds ;
3435 _enableMultipleHttp2Connections = false ;
@@ -145,6 +146,23 @@ public string? RootCertificate
145146
146147 private string ? _rootCertificate ;
147148
149+ public int ConnectTimeout
150+ {
151+ get => _connectTimeout ;
152+ set
153+ {
154+ if ( value < 0 )
155+ {
156+ throw new ArgumentOutOfRangeException ( nameof ( value ) , value , "Invalid connect timeout: " + value ) ;
157+ }
158+
159+ _connectTimeout = value ;
160+ SaveValue ( nameof ( ConnectTimeout ) , value ) ;
161+ }
162+ }
163+
164+ private int _connectTimeout ;
165+
148166 public int KeepAlivePingDelay
149167 {
150168 get => _keepAlivePingDelay ;
@@ -283,6 +301,9 @@ internal async Task<IDriver> BuildDriver()
283301 customServerCertificates : ServerCertificates
284302 )
285303 {
304+ ConnectTimeout = ConnectTimeout == 0
305+ ? Timeout . InfiniteTimeSpan
306+ : TimeSpan . FromSeconds ( ConnectTimeout ) ,
286307 KeepAlivePingDelay = KeepAlivePingDelay == 0
287308 ? Timeout . InfiniteTimeSpan
288309 : TimeSpan . FromSeconds ( KeepAlivePingDelay ) ,
@@ -367,10 +388,12 @@ static YdbConnectionOption()
367388 "MaxSessionPool" , "Max Session Pool" , "Maximum Pool Size" , "Max Pool Size" , "MaximumPoolSize" ) ;
368389 AddOption ( new YdbConnectionOption < bool > ( BoolExtractor , ( builder , useTls ) => builder . UseTls = useTls ) ,
369390 "UseTls" , "Use Tls" ) ;
370- AddOption (
371- new YdbConnectionOption < string > ( StringExtractor ,
391+ AddOption ( new YdbConnectionOption < string > ( StringExtractor ,
372392 ( builder , rootCertificate ) => builder . RootCertificate = rootCertificate ) ,
373393 "RootCertificate" , "Root Certificate" ) ;
394+ AddOption ( new YdbConnectionOption < int > ( IntExtractor ,
395+ ( builder , connectTimeout ) => builder . ConnectTimeout = connectTimeout ) ,
396+ "ConnectTimeout" , "Connect Timeout" ) ;
374397 AddOption ( new YdbConnectionOption < int > ( IntExtractor ,
375398 ( builder , keepAlivePingDelay ) => builder . KeepAlivePingDelay = keepAlivePingDelay ) ,
376399 "KeepAlivePingDelay" , "Keep Alive Ping Delay" ) ;
0 commit comments