Skip to content

Commit f4aed6f

Browse files
authored
Merge pull request kubernetes-client#630 from bacongobbler/keepalive
send keep-alive probes every 30 seconds to the server
2 parents 5dd9180 + c68c268 commit f4aed6f

File tree

3 files changed

+90
-5
lines changed

3 files changed

+90
-5
lines changed

package-lock.json

Lines changed: 83 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"isomorphic-ws": "^4.0.1",
6767
"js-yaml": "^3.13.1",
6868
"jsonpath-plus": "^0.19.0",
69+
"net-keepalive": "2.0.4",
6970
"openid-client": "^4.1.1",
7071
"request": "^2.88.0",
7172
"rfc4648": "^1.3.0",

src/watch.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import byline = require('byline');
2+
import keepalive = require('net-keepalive');
23
import request = require('request');
34
import { Duplex } from 'stream';
45
import { KubeConfig } from './config';
@@ -112,6 +113,11 @@ export class Watch {
112113
req = this.requestImpl.webRequest(requestOptions);
113114
const stream = byline.createStream();
114115
req.on('error', doneCallOnce);
116+
req.on('socket', (socket) => {
117+
socket.setTimeout(30000);
118+
socket.setKeepAlive(true);
119+
keepalive.setKeepAliveInterval(socket, 30000);
120+
});
115121
stream.on('error', doneCallOnce);
116122
stream.on('close', () => doneCallOnce(null));
117123
stream.on('data', (line) => {

0 commit comments

Comments
 (0)