fix: Properly assign connection pools for JW proxy
MODIFY
lib/jsonwp-proxy/proxy.js
lib/jsonwp-proxy/proxy.js
@@ -33,12 +33,19 @@ class JWProxy {
reqBasePath: DEFAULT_BASE_PATH,
sessionId: null,
timeout: DEFAULT_REQUEST_TIMEOUT,
- keepAlive: true,
});
this.scheme = this.scheme.toLowerCase();
this._activeRequests = [];
this._reqCancelSource = axios.CancelToken.source();
this._downstreamProtocol = null;
+ const agentOpts = {
+ keepAlive: opts.keepAlive ?? true,
+ maxSockets: 30,
+ maxFreeSockets: 10,
+ timeout: 60000,
+ };
+ this.httpAgent = new http.Agent(agentOpts);
+ this.httpsAgent = new https.Agent(agentOpts);
this.protocolConverter = new ProtocolConverter(this.proxy.bind(this));
}
@@ -149,8 +156,8 @@ class JWProxy {
accept: 'application/json, */*',
},
timeout: this.timeout,
- httpAgent: new http.Agent({ keepAlive: this.keepAlive }),
- httpsAgent: new https.Agent({ keepAlive: this.keepAlive }),
+ httpAgent: this.httpAgent,
+ httpsAgent: this.httpsAgent,
cancelToken: this._reqCancelSource.token,
};
// GET methods shouldn't have any body. Most servers are OK with this, but WebDriverAgent throws 400 errors

fix: Properly assign connection pools for JW proxy (#416)