Skip to content

Commit

Permalink
Add http2 keep alive in watch (#781)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiweiv authored Feb 17, 2022
1 parent 408610f commit 29f9aa9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/KubernetesClient/Kubernetes.ConfigInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,12 @@ private void CreateHttpClient(DelegatingHandler[] handlers, KubernetesClientConf
//
// Should remove after better solution

var sh = new SocketsHttpHandler();
var sh = new SocketsHttpHandler
{
KeepAlivePingPolicy = HttpKeepAlivePingPolicy.WithActiveRequests,
KeepAlivePingDelay = TimeSpan.FromMinutes(3),
KeepAlivePingTimeout = TimeSpan.FromSeconds(30),
};
sh.ConnectCallback = async (context, token) =>
{
var socket = new Socket(SocketType.Stream, ProtocolType.Tcp)
Expand Down

6 comments on commit 29f9aa9

@Paciv
Copy link
Contributor

@Paciv Paciv commented on 29f9aa9 Apr 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did hack (reflection) to change the value, but it would be nice to have them available on the KubernetesConfiguration object instead

@tg123
Copy link
Member

@tg123 tg123 commented on 29f9aa9 Apr 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is included in latest release

@Paciv
Copy link
Contributor

@Paciv Paciv commented on 29f9aa9 Apr 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant being able to set those value on the KubernetesClientConfiguration object instead of having to use the fixed values from this code.

var kubernetesClientConfiguration = KubernetesClientConfiguration.BuildConfigFromConfigFile();
kubernetesClientConfiguration.KeepAlivePingPolicy = HttpKeepAlivePingPolicy.Always;
kubernetesClientConfiguration.KeepAlivePingDelay = TimeSpan.FromSeconds(30);

@tg123
Copy link
Member

@tg123 tg123 commented on 29f9aa9 Apr 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please drop a PR to add them?
it is on my very long todo list

@Paciv
Copy link
Contributor

@Paciv Paciv commented on 29f9aa9 Apr 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check. But I still have intermittent disconnections, around once per hour. not a reset by peer error though, just the close event raised on the watch.
I was wondering why you removed the code on the ConnectCallback. I didn't looked it up, but from what I can read in the issue linked the behavior won't be changed on framework side.

@tg123
Copy link
Member

@tg123 tg123 commented on 29f9aa9 Apr 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Paciv tcp keep alive is not easy to setup and replaced with http2 keepalive here

Please sign in to comment.