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

Using unix domain socket in connection string fails server selection

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 4.9.0
    • Affects Version/s: None
    • Component/s: None
    • 0
    • Not Needed

      What problem are you facing?

      Cannot connect to MongoDB using unix domain socket, server selection fails. It will work only with localhost:27017, but if you inspect the variables a number of port/host properties on connection/node socket/server description is undefined implying this only works because of some defaults.

      What driver and relevant dependency versions are you using?

      4.x, this works in 3.x

      Steps to reproduce?

      Sample connection string

      mongodb://bob:pwd123@%2Ftmp%2Fmongodb-31000.sock,%2Ftmp%2Fmongodb-31001.sock,%2Ftmp%2Fmongodb-31002.sock/
      
      const host = [31000, 31001, 31002].map(p => encodeURIComponent(`/tmp/mongodb-${p}.sock`)).join(',');
      const cs = `mongodb://bob:pwd123@${host}/`;
      
      const client = new MongoClient(cs, { serverSelectionTimeoutMS: 3000 });
      await client.connect(); // fails server selection
      

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

              Created:
              Updated:
              Resolved: