Skip to content

Commit bd762eb

Browse files
author
Matthew Fisher
committed
set keepalive header on watch requests
This fix sends keep-alive probes to the server every 30 seconds. Signed-off-by: Matthew Fisher <[email protected]>
1 parent 5dd9180 commit bd762eb

File tree

3 files changed

+89
-5
lines changed

3 files changed

+89
-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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import byline = require('byline');
22
import request = require('request');
3+
import keepalive = require('net-keepalive');
34
import { Duplex } from 'stream';
45
import { KubeConfig } from './config';
56

@@ -112,6 +113,10 @@ export class Watch {
112113
req = this.requestImpl.webRequest(requestOptions);
113114
const stream = byline.createStream();
114115
req.on('error', doneCallOnce);
116+
req.on('socket', function(socket) {
117+
socket.setKeepAlive(true);
118+
keepalive.setKeepAliveInterval(socket, 30000);
119+
});
115120
stream.on('error', doneCallOnce);
116121
stream.on('close', () => doneCallOnce(null));
117122
stream.on('data', (line) => {

0 commit comments

Comments
 (0)