We have a replica set across three Azure Windows VMs. When a Node.js application hosted on a separate Windows VM, and when it tries to connect we get this error:
Applications written in C# can connect without issue, as can the MongoDB CLI.
We are using mongodb-core v3.1.0. After adding some console logging to mongodb-core\lib\connection\connection.js (around line 595) it looks like the cause of the problem
is that the driver is removing the domain qualification from the server names. Our connection string is mongodb://SERVER01.domain.company.com,[SERVER02.domain.company.com|http://server02.domain.company.com/],[SERVER03.domain.company.com|http://server03.domain.company.com/].
Initially connections are made to all 3 nodes using the FQDN (first using IPv6 then falling back to IPv4), but immediately afterwards connections are attempted using just the host name, which fails.
When there is no replica set only the initial connection, using the FQDN, is made. Oddly, Node's DNS can resolve both SERVER01.domain.company.com and server01 to the correct IP address, e.g. using dns.lookup.
Is this a bug in the driver, or are we missing some configuration somewhere?