Skip to content

Commit ea1c59f

Browse files
committed
Add http2 keep alive in watch
1 parent 8f4ee45 commit ea1c59f

File tree

3 files changed

+63
-58
lines changed

3 files changed

+63
-58
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
1-
name: "CodeQL"
2-
3-
on:
4-
push:
5-
branches: [ master ]
6-
pull_request:
7-
# The branches below must be a subset of the branches above
8-
branches: [ master ]
9-
schedule:
10-
- cron: '15 23 * * 1'
11-
12-
jobs:
13-
analyze:
14-
name: Analyze
15-
runs-on: windows-latest
16-
17-
strategy:
18-
fail-fast: false
19-
matrix:
20-
language: [ 'csharp' ]
21-
22-
steps:
23-
- name: Checkout repository
24-
uses: actions/checkout@v2
25-
with:
26-
fetch-depth: 0
27-
28-
- name: Setup dotnet SDK 3.1
29-
uses: actions/setup-dotnet@v1
30-
with:
31-
dotnet-version: '3.1.x'
32-
- name: Setup dotnet SDK 5
33-
uses: actions/setup-dotnet@v1
34-
with:
35-
dotnet-version: '5.0.x'
36-
- name: Setup dotnet SDK 6
37-
uses: actions/setup-dotnet@v1
38-
with:
39-
dotnet-version: '6.0.x'
40-
41-
# Initializes the CodeQL tools for scanning.
42-
- name: Initialize CodeQL
43-
uses: github/codeql-action/init@v1
44-
with:
45-
languages: ${{ matrix.language }}
46-
# If you wish to specify custom queries, you can do so here or in a config file.
47-
# By default, queries listed here will override any specified in a config file.
48-
# Prefix the list here with "+" to use these queries and those in the config file.
49-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
50-
51-
- name: Autobuild
52-
uses: github/codeql-action/autobuild@v1
53-
54-
- name: Perform CodeQL Analysis
55-
uses: github/codeql-action/analyze@v1
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
# The branches below must be a subset of the branches above
8+
branches: [ master ]
9+
schedule:
10+
- cron: '15 23 * * 1'
11+
12+
jobs:
13+
analyze:
14+
name: Analyze
15+
runs-on: windows-2019
16+
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
language: [ 'csharp' ]
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v2
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Setup dotnet SDK 3.1
29+
uses: actions/setup-dotnet@v1
30+
with:
31+
dotnet-version: '3.1.x'
32+
- name: Setup dotnet SDK 5
33+
uses: actions/setup-dotnet@v1
34+
with:
35+
dotnet-version: '5.0.x'
36+
- name: Setup dotnet SDK 6
37+
uses: actions/setup-dotnet@v1
38+
with:
39+
dotnet-version: '6.0.x'
40+
41+
# Initializes the CodeQL tools for scanning.
42+
- name: Initialize CodeQL
43+
uses: github/codeql-action/init@v1
44+
with:
45+
languages: ${{ matrix.language }}
46+
# If you wish to specify custom queries, you can do so here or in a config file.
47+
# By default, queries listed here will override any specified in a config file.
48+
# Prefix the list here with "+" to use these queries and those in the config file.
49+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
50+
51+
- name: Autobuild
52+
uses: github/codeql-action/autobuild@v1
53+
54+
- name: Perform CodeQL Analysis
55+
uses: github/codeql-action/analyze@v1

src/KubernetesClient/Kubernetes.ConfigInit.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ private void CreateHttpClient(DelegatingHandler[] handlers, KubernetesClientConf
176176
FirstMessageHandler = HttpClientHandler = CreateRootHandler();
177177

178178

179-
#if NET5_0
179+
#if NET5_0_OR_GREATER
180180
// https://github.com/kubernetes-client/csharp/issues/587
181181
// let user control if tcp keep alive until better fix
182182
if (config.TcpKeepAlive)
@@ -192,7 +192,12 @@ private void CreateHttpClient(DelegatingHandler[] handlers, KubernetesClientConf
192192
//
193193
// Should remove after better solution
194194

195-
var sh = new SocketsHttpHandler();
195+
var sh = new SocketsHttpHandler
196+
{
197+
KeepAlivePingPolicy = HttpKeepAlivePingPolicy.WithActiveRequests,
198+
KeepAlivePingDelay = TimeSpan.FromMinutes(3),
199+
KeepAlivePingTimeout = TimeSpan.FromSeconds(30),
200+
};
196201
sh.ConnectCallback = async (context, token) =>
197202
{
198203
var socket = new Socket(SocketType.Stream, ProtocolType.Tcp)

src/KubernetesClient/Kubernetes.WebSocket.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ protected async Task<WebSocket> StreamConnectAsync(Uri uri, string webSocketSubP
300300
}
301301
else
302302
{
303-
#if NET5_0
303+
#if NET5_0_OR_GREATER
304304
var content = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
305305
#else
306306
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

0 commit comments

Comments
 (0)