Skip to content

Commit

Permalink
expose keep-alive timeout on command-line
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk committed Aug 17, 2023
1 parent ebeb1ea commit 1495793
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions bin/configurable-http-proxy
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ cli
.option(
"--storage-backend <storage-class>",
"Define an external storage class. Defaults to in-MemoryStore."
)
.option(
"--keep-alive-timeout <timeout>",
"Set timeout (in milliseconds) for Keep-Alive connections",
5000
);

// collects multiple flags to an object
Expand Down Expand Up @@ -269,6 +274,8 @@ options.redirectTo = args.redirectTo;
options.headers = args.customHeader;
options.timeout = args.timeout;
options.proxyTimeout = args.proxyTimeout;
// cast to milliseconds, which is what
options.keepAliveTimeout = args.keepAliveTimeout;

// metrics options
options.enableMetrics = !!args.metricsPort;
Expand Down
6 changes: 5 additions & 1 deletion lib/configproxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,11 @@ class ConfigurableProxy extends EventEmitter {
this.metricsServer = http.createServer(metricsCallback);
}

var httpOptions = { keepAlive: true, agent: this.agent };
var httpOptions = {
keepAlive: true,
agent: this.agent,
keepAliveTimeout: this.options.keepAliveTimeout || 5000,
};

// proxy requests separately
var proxyCallback = logErrors(this.handleProxyWeb);
Expand Down

0 comments on commit 1495793

Please sign in to comment.