Using unix domain socket in connection string fails server selection

XMLWordPrintableJSON

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

      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
              Reporter:
              Neal Beeken
              Daria Pardue
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: