@@ -27,6 +27,8 @@ private void InitDefaultValues()
2727 _database = "/local" ;
2828 _maxSessionPool = 100 ;
2929 _useTls = false ;
30+ _keepAlivePingDelay = SocketHttpHandlerDefaults . DefaultKeepAlivePingSeconds ;
31+ _keepAlivePingTimeout = SocketHttpHandlerDefaults . DefaultKeepAlivePingTimeoutSeconds ;
3032 }
3133
3234 public string Host
@@ -137,6 +139,41 @@ public string? RootCertificate
137139
138140 private string ? _rootCertificate ;
139141
142+ public int KeepAlivePingDelay
143+ {
144+ get => _keepAlivePingDelay ;
145+ set
146+ {
147+ if ( value < 0 )
148+ {
149+ throw new ArgumentOutOfRangeException ( nameof ( value ) , value , "Invalid keep alive ping delay: " + value ) ;
150+ }
151+
152+ _keepAlivePingDelay = value ;
153+ SaveValue ( nameof ( KeepAlivePingDelay ) , value ) ;
154+ }
155+ }
156+
157+ private int _keepAlivePingDelay ;
158+
159+ public int KeepAlivePingTimeout
160+ {
161+ get => _keepAlivePingTimeout ;
162+ set
163+ {
164+ if ( value < 0 )
165+ {
166+ throw new ArgumentOutOfRangeException ( nameof ( value ) , value ,
167+ "Invalid keep alive ping timeout: " + value ) ;
168+ }
169+
170+ _keepAlivePingTimeout = value ;
171+ SaveValue ( nameof ( KeepAlivePingTimeout ) , value ) ;
172+ }
173+ }
174+
175+ private int _keepAlivePingTimeout ;
176+
140177 public ILoggerFactory ? LoggerFactory { get ; init ; }
141178
142179 public ICredentialsProvider ? CredentialsProvider { get ; init ; }
@@ -193,7 +230,15 @@ internal Task<Driver> BuildDriver()
193230 credentials : credentialsProvider ,
194231 customServerCertificate : cert ,
195232 customServerCertificates : ServerCertificates
196- ) , LoggerFactory ) ;
233+ )
234+ {
235+ KeepAlivePingDelay = KeepAlivePingDelay == 0
236+ ? Timeout . InfiniteTimeSpan
237+ : TimeSpan . FromSeconds ( KeepAlivePingDelay ) ,
238+ KeepAlivePingTimeout = KeepAlivePingTimeout == 0
239+ ? Timeout . InfiniteTimeSpan
240+ : TimeSpan . FromSeconds ( KeepAlivePingTimeout )
241+ } , LoggerFactory ) ;
197242 }
198243
199244 public override void Clear ( )
@@ -265,6 +310,12 @@ static YdbConnectionOption()
265310 new YdbConnectionOption < string > ( StringExtractor ,
266311 ( builder , rootCertificate ) => builder . RootCertificate = rootCertificate ) ,
267312 "RootCertificate" , "Root Certificate" ) ;
313+ AddOption ( new YdbConnectionOption < int > ( IntExtractor ,
314+ ( builder , keepAlivePingDelay ) => builder . KeepAlivePingDelay = keepAlivePingDelay ) ,
315+ "KeepAlivePingDelay" , "Keep Alive Ping Delay" ) ;
316+ AddOption ( new YdbConnectionOption < int > ( IntExtractor ,
317+ ( builder , keepAlivePingTimeout ) => builder . KeepAlivePingTimeout = keepAlivePingTimeout ) ,
318+ "KeepAlivePingTimeout" , "Keep Alive Ping Timeout" ) ;
268319 }
269320
270321 private static void AddOption ( YdbConnectionOption option , params string [ ] keys )
0 commit comments