@itentialopensource/adapter-utils 6.0.2 → 6.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/connectorRest.js
CHANGED
|
@@ -110,6 +110,7 @@ let numRetries = 3;
|
|
|
110
110
|
let numRedirects = 0;
|
|
111
111
|
let limitRetryError = [0];
|
|
112
112
|
let attemptTimeout = 5000;
|
|
113
|
+
let keepAliveInterval = 0;
|
|
113
114
|
let healthcheckOnTimeout = true;
|
|
114
115
|
let globalRequest = null;
|
|
115
116
|
let archiving = false;
|
|
@@ -878,6 +879,20 @@ function makeRequest(request, entitySchema, callProperties, startTrip, attempt,
|
|
|
878
879
|
});
|
|
879
880
|
});
|
|
880
881
|
|
|
882
|
+
// Enable TCP keep-alive on the socket if configured
|
|
883
|
+
// Minimum value enforced: 30000ms (30 seconds)
|
|
884
|
+
if (keepAliveInterval > 0 && keepAliveInterval < 30000) {
|
|
885
|
+
// Auto-correct to minimum value
|
|
886
|
+
log.warn(`${id}-connectorRest-makeRequest: keep_alive_interval (${keepAliveInterval}ms) is below minimum (30000ms). Using 30000ms.`);
|
|
887
|
+
httpRequest.on('socket', (socket) => {
|
|
888
|
+
socket.setKeepAlive(true, 30000);
|
|
889
|
+
});
|
|
890
|
+
} else if (keepAliveInterval >= 30000) {
|
|
891
|
+
httpRequest.on('socket', (socket) => {
|
|
892
|
+
socket.setKeepAlive(true, keepAliveInterval);
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
|
|
881
896
|
// handle post error
|
|
882
897
|
httpRequest.on('error', (cerror) => {
|
|
883
898
|
const tripDiff = process.hrtime(roundTTime);
|
|
@@ -4444,6 +4459,19 @@ class ConnectorRest {
|
|
|
4444
4459
|
if (typeof props.request.return_request === 'boolean') {
|
|
4445
4460
|
returnRequest = props.request.return_request;
|
|
4446
4461
|
}
|
|
4462
|
+
|
|
4463
|
+
// set the TCP keep-alive interval (optional - default is 0/disabled)
|
|
4464
|
+
// Minimum value of 30000ms (30 seconds) enforced at point of use
|
|
4465
|
+
if (typeof props.request.keep_alive_interval === 'number'
|
|
4466
|
+
|| typeof props.request.keep_alive_interval === 'string') {
|
|
4467
|
+
keepAliveInterval = Number(props.request.keep_alive_interval);
|
|
4468
|
+
|
|
4469
|
+
// Validate the parsed value
|
|
4470
|
+
if (Number.isNaN(keepAliveInterval)) {
|
|
4471
|
+
log.error(`${id}-connectorRest: Invalid keep_alive_interval value "${props.request.keep_alive_interval}". Using default 0 (disabled).`);
|
|
4472
|
+
keepAliveInterval = 0;
|
|
4473
|
+
}
|
|
4474
|
+
}
|
|
4447
4475
|
}
|
|
4448
4476
|
|
|
4449
4477
|
if (props.proxy) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itentialopensource/adapter-utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.7",
|
|
4
4
|
"description": "Itential Adapter Utility Libraries",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"postinstall": "node utils/setup.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"https-proxy-agent": "^7.0.0",
|
|
36
36
|
"json-query": "^2.2.2",
|
|
37
37
|
"jsontoxml": "^1.0.1",
|
|
38
|
-
"jsonwebtoken": "^9.0.
|
|
38
|
+
"jsonwebtoken": "^9.0.3",
|
|
39
39
|
"mongodb": "^3.7.4",
|
|
40
40
|
"readline-sync": "^1.4.10",
|
|
41
41
|
"socks-proxy-agent": "^8.0.1",
|
|
@@ -790,6 +790,13 @@
|
|
|
790
790
|
"type": "boolean",
|
|
791
791
|
"description": "This property turns on returning the response information - need to be carefull in case credentials are in the path",
|
|
792
792
|
"default": false
|
|
793
|
+
},
|
|
794
|
+
"keep_alive_interval": {
|
|
795
|
+
"type": "integer",
|
|
796
|
+
"description": "TCP keep-alive interval in milliseconds to prevent connection timeout during long-running requests. 0 = disabled (default). Minimum value when enabled is 30000ms (30 seconds). Values below 30000ms will be auto-corrected to 30000ms with a warning.",
|
|
797
|
+
"default": 0,
|
|
798
|
+
"minimum": 0,
|
|
799
|
+
"maximum": 3600000
|
|
793
800
|
}
|
|
794
801
|
},
|
|
795
802
|
"required": [
|