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

MongoClient URL does not support IPv6 addresses

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 1.4
    • Component/s: None
    • Labels:

      http://mongodb.github.io/node-mongodb-native/driver-articles/mongoclient.html

      Documentation there says it supports IP address ... but it does not say anything about IPv6.

      Looking at the source, it seems it simply splits the host at the colon ":" ... which does not work when using IPv6 addresses (e.g. ::1)

          // Split up the db
          hostPart = connection_part;
          // Parse all server results
          servers = hostPart.split(',').map(function(h) {
            var hostPort = h.split(':', 2);
            var _host = hostPort[0] || 'localhost';
            var _port = hostPort[1] != null ? parseInt(hostPort[1], 10) : 27017;
            // Check for localhost?safe=true style case
            if(_host.indexOf("?") != -1) _host = _host.split(/\?/)[0];
      
            // Return the mapped object
            return {host: _host, port: _port};
          });
      

      Should fix the documentation to explicitly say only IPv4 supported, or improve the parsing logic to handle IPv6.

            Assignee:
            christkv Christian Amor Kvalheim
            Reporter:
            micovery Miguel Mendoza
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: