Skip to content

Commit ffc0f55

Browse files
committed
fix: reduce default keepalive time to align with Azure defaults
The default TCP idle timeout on the Azure load balancer is 240 seconds, meaning it could silently drop connections if they begin experiencing higher latency. In order to avoid dropped connections we reduce our TCP keepalive initial delay to 120s, half the max time for the load balancer. NODE-2627
1 parent edf1309 commit ffc0f55

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/cmap/connect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ function makeConnection(family, options, cancellationToken, _callback) {
233233
const useSsl = typeof options.ssl === 'boolean' ? options.ssl : false;
234234
const keepAlive = typeof options.keepAlive === 'boolean' ? options.keepAlive : true;
235235
let keepAliveInitialDelay =
236-
typeof options.keepAliveInitialDelay === 'number' ? options.keepAliveInitialDelay : 300000;
236+
typeof options.keepAliveInitialDelay === 'number' ? options.keepAliveInitialDelay : 120000;
237237
const noDelay = typeof options.noDelay === 'boolean' ? options.noDelay : true;
238238
const connectionTimeout =
239239
typeof options.connectionTimeout === 'number'

lib/mongo_client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const PromiseProvider = require('./promise_provider');
9494
* @param {boolean} [options.autoReconnect=true] Enable autoReconnect for single server instances
9595
* @param {boolean} [options.noDelay=true] TCP Connection no delay
9696
* @param {boolean} [options.keepAlive=true] TCP Connection keep alive enabled
97-
* @param {number} [options.keepAliveInitialDelay=30000] The number of milliseconds to wait before initiating keepAlive on the TCP socket
97+
* @param {number} [options.keepAliveInitialDelay=120000] The number of milliseconds to wait before initiating keepAlive on the TCP socket
9898
* @param {number} [options.connectTimeoutMS=10000] How long to wait for a connection to be established before timing out
9999
* @param {number} [options.socketTimeoutMS=360000] How long a send or receive on a socket can take before timing out
100100
* @param {number} [options.family] Version of IP stack. Can be 4, 6 or null (default).
@@ -345,7 +345,7 @@ MongoClient.prototype.isConnected = function(options) {
345345
* @param {boolean} [options.autoReconnect=true] Enable autoReconnect for single server instances
346346
* @param {boolean} [options.noDelay=true] TCP Connection no delay
347347
* @param {boolean} [options.keepAlive=true] TCP Connection keep alive enabled
348-
* @param {boolean} [options.keepAliveInitialDelay=30000] The number of milliseconds to wait before initiating keepAlive on the TCP socket
348+
* @param {number} [options.keepAliveInitialDelay=120000] The number of milliseconds to wait before initiating keepAlive on the TCP socket
349349
* @param {number} [options.connectTimeoutMS=10000] How long to wait for a connection to be established before timing out
350350
* @param {number} [options.socketTimeoutMS=360000] How long a send or receive on a socket can take before timing out
351351
* @param {number} [options.family] Version of IP stack. Can be 4, 6 or null (default).

0 commit comments

Comments
 (0)