Skip to content

Commit

Permalink
Merge pull request #630 from bacongobbler/keepalive
Browse files Browse the repository at this point in the history
send keep-alive probes every 30 seconds to the server
  • Loading branch information
k8s-ci-robot authored Apr 7, 2021
2 parents 5dd9180 + c68c268 commit f4aed6f
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 5 deletions.
88 changes: 83 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"isomorphic-ws": "^4.0.1",
"js-yaml": "^3.13.1",
"jsonpath-plus": "^0.19.0",
"net-keepalive": "2.0.4",
"openid-client": "^4.1.1",
"request": "^2.88.0",
"rfc4648": "^1.3.0",
Expand Down
6 changes: 6 additions & 0 deletions src/watch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import byline = require('byline');
import keepalive = require('net-keepalive');
import request = require('request');
import { Duplex } from 'stream';
import { KubeConfig } from './config';
Expand Down Expand Up @@ -112,6 +113,11 @@ export class Watch {
req = this.requestImpl.webRequest(requestOptions);
const stream = byline.createStream();
req.on('error', doneCallOnce);
req.on('socket', (socket) => {
socket.setTimeout(30000);
socket.setKeepAlive(true);
keepalive.setKeepAliveInterval(socket, 30000);
});
stream.on('error', doneCallOnce);
stream.on('close', () => doneCallOnce(null));
stream.on('data', (line) => {
Expand Down

0 comments on commit f4aed6f

Please sign in to comment.