Skip to content

Commit

Permalink
fix: reduce default keepalive time to align with Azure defaults
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mbroadst committed Jun 3, 2020
1 parent edf1309 commit ffc0f55
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/cmap/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ function makeConnection(family, options, cancellationToken, _callback) {
const useSsl = typeof options.ssl === 'boolean' ? options.ssl : false;
const keepAlive = typeof options.keepAlive === 'boolean' ? options.keepAlive : true;
let keepAliveInitialDelay =
typeof options.keepAliveInitialDelay === 'number' ? options.keepAliveInitialDelay : 300000;
typeof options.keepAliveInitialDelay === 'number' ? options.keepAliveInitialDelay : 120000;
const noDelay = typeof options.noDelay === 'boolean' ? options.noDelay : true;
const connectionTimeout =
typeof options.connectionTimeout === 'number'
Expand Down
4 changes: 2 additions & 2 deletions lib/mongo_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const PromiseProvider = require('./promise_provider');
* @param {boolean} [options.autoReconnect=true] Enable autoReconnect for single server instances
* @param {boolean} [options.noDelay=true] TCP Connection no delay
* @param {boolean} [options.keepAlive=true] TCP Connection keep alive enabled
* @param {number} [options.keepAliveInitialDelay=30000] The number of milliseconds to wait before initiating keepAlive on the TCP socket
* @param {number} [options.keepAliveInitialDelay=120000] The number of milliseconds to wait before initiating keepAlive on the TCP socket
* @param {number} [options.connectTimeoutMS=10000] How long to wait for a connection to be established before timing out
* @param {number} [options.socketTimeoutMS=360000] How long a send or receive on a socket can take before timing out
* @param {number} [options.family] Version of IP stack. Can be 4, 6 or null (default).
Expand Down Expand Up @@ -345,7 +345,7 @@ MongoClient.prototype.isConnected = function(options) {
* @param {boolean} [options.autoReconnect=true] Enable autoReconnect for single server instances
* @param {boolean} [options.noDelay=true] TCP Connection no delay
* @param {boolean} [options.keepAlive=true] TCP Connection keep alive enabled
* @param {boolean} [options.keepAliveInitialDelay=30000] The number of milliseconds to wait before initiating keepAlive on the TCP socket
* @param {number} [options.keepAliveInitialDelay=120000] The number of milliseconds to wait before initiating keepAlive on the TCP socket
* @param {number} [options.connectTimeoutMS=10000] How long to wait for a connection to be established before timing out
* @param {number} [options.socketTimeoutMS=360000] How long a send or receive on a socket can take before timing out
* @param {number} [options.family] Version of IP stack. Can be 4, 6 or null (default).
Expand Down

0 comments on commit ffc0f55

Please sign in to comment.