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

Cannot connect to IPv6 hosts with 4.9.0+ driver

    • 3
    • Not Needed
    • Not Needed

      import { MongoClient } from 'mongodb-4.9.1';
      await MongoClient.connect(`mongodb://[::1]:27444/`); 

      fails with

      $ node test.mjs
      node:internal/errors:477
          ErrorCaptureStackTrace(err);
          ^TypeError [ERR_INVALID_URL]: Invalid URL
          at new NodeError (node:internal/errors:387:5)
          at URL.onParseError (node:internal/url:564:9)
          at new URL (node:internal/url:640:5)
          at new HostAddress (/tmp/z/node_modules/mongodb-4.9.1/lib/utils.js:882:36)
          at Function.fromString (/tmp/z/node_modules/mongodb-4.9.1/lib/utils.js:932:16)
          at ServerDescription.get hostAddress [as hostAddress] (/tmp/z/node_modules/mongodb-4.9.1/lib/sdam/server_description.js:66:36)
          at new Server (/tmp/z/node_modules/mongodb-4.9.1/lib/sdam/server.js:31:56)
          at createAndConnectServer (/tmp/z/node_modules/mongodb-4.9.1/lib/sdam/topology.js:477:20)
          at /tmp/z/node_modules/mongodb-4.9.1/lib/sdam/topology.js:175:13
          at Array.map (<anonymous>) {
        input: 'mongodb://::1:27444',
        code: 'ERR_INVALID_URL'
      } 

      4.8.1 does not exhibit this behavior.

       

      AC

      • Pass true to the toString method on host address objects in the server description.
      • This is reproducible locally, make sure that this works in your local.
      • Add a unit test that verifies the IPV6 address string on the server description matches the key in the descriptions map in the topology.
      • if IPV4 is a simple test, add a regression test.

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            anna.henningsen@mongodb.com Anna Henningsen
            Daria Pardue
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: