-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 3.1.0
-
Component/s: Core
-
Empty show more show less
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:
ERROR MongoNetworkError: failed to connect to server [server01:27017] on first connect [MongoNetworkError: getaddrinfo ENOTFOUND server01 server01:27017]
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.
Example logs:
MONGODB CONNECTION { port: 27017, host: 'SERVER01.domain.company.com', family: 6 } MONGODB CONNECTION { port: 27017, host: 'SERVER02.domain.company.com', family: 6 } MONGODB CONNECTION { port: 27017, host: 'SERVER03.domain.company.com', family: 6 } MONGODB CONNECTION { port: 27017, host: 'SERVER01.domain.company.com', family: 4 } MONGODB CONNECTION { port: 27017, host: 'SERVER02.domain.company.com', family: 4 } MONGODB CONNECTION { port: 27017, host: 'SERVER03.domain.company.com', family: 4 } MONGODB CONNECTION { port: 27017, host: 'server01', family: 6 } MONGODB CONNECTION { port: 27017, host: 'server02', family: 6 } MONGODB CONNECTION { port: 27017, host: 'server03', family: 6 } MONGODB CONNECTION { port: 27017, host: 'server03', family: 4 } MONGODB CONNECTION { port: 27017, host: 'server02', family: 4 } MONGODB CONNECTION { port: 27017, host: 'server01', family: 4 }
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?
- is related to
-
NODE-2143 getaddrinfo ENOTFOUND error on Windows 10 due to failed fallback to ipv4 after ipv6 lookup fails
- Closed
- related to
-
COMPASS-3801 Compass on Windows 10 fails to connect to replica set (except via IP address)
- Closed