Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-87

In HA mode, after first reconnect, driver keeps reconnecting every 30 sec.

      Context: replset with 3 nodes; connecting to it using all default parameters.
      Problem: after replset master re-election or a rs.reconfig() command, I see in mongodb logs that the client reconnects whole connection pool (5 conns) every 30 seconds.

      I tracked the source of the problem to the _reconnect_servers function in /connection/repl_set/ha.js file. When it runs, new connection pool is established, with 'socketTimeoutMS' parameter set to 30000. Unlike in HighAvailabilityProcess.prototype.start function above, the db linked to connection is not queried every haInterval (default 2 seconds), so the connection is idle and timed out after 30 seconds, which triggers a reconnect.

      So, I would suggest to either set socketTimeoutMS=0 in the aforementioned function, or provide an app-level keepalive functionality like with the haInterval (TCP-level keepAlive will not work, as it doesn't reset the timer).

            Assignee:
            christkv Christian Amor Kvalheim
            Reporter:
            ashtuchkin Alexander Shtuchkin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: