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

Srv resolution options taking precedence over connection string params

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Not Needed

      What problem are you facing?

      With driver 4.0 the srv resolution sets some connection options overriding what the user specifies directly in the connection string. In compass we verified that this applies for tls: true but could probably also affect those params that are taken from the TXT record: authSource, replicaSet and loadBalanced.

      This seems to prevent users from connecting with srv+mongo with tls/ssl disabled in Compass and Mongodb for VSCode: https://jira.mongodb.org/browse/COMPASS-4928

      Mongosh is not affected by this issue since srv records are resolved independently.

      What driver and relevant dependency versions are you using?

      4.0.0-beta.6

      Steps to reproduce?

      > require('mongodb/package.json').version
      "4.0.0-beta.6"
      > new (require('mongodb').MongoClient)('mongodb+srv://root:password123@srv-test.mongodb.dev/db1?ssl=false').connect(console.log)
      undefined
      > MongoServerSelectionError: Client network socket disconnected before secure TLS connection was established
      

      3.6 used to connect:

      > require('mongodb/package.json').version
      "3.6.9"
      > new (require('mongodb').MongoClient)('mongodb+srv://root:password123@srv-test.mongodb.dev/db1?ssl=false').connect(console.log)
      undefined
      > null MongoClient {_events: {…}, _eventsCount: 0, _maxListeners: undefined, s: {…}, topology: ReplSet}
      

      On our side we would be happy with a workaround for now, but nothing that we tried seemed to work: tls:true as option for `MongoClient` is overridden and ssl:true only throws a different error:

      new (require('mongodb').MongoClient)('mongodb+srv://root:password123@srv-test.mongodb.dev/db1?ssl=false', { ssl: false }).connect(console.log)
      connection_string.ts:367 Uncaught MongoParseError: All values of ssl must be the same.
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            maurizio.casimirri@mongodb.com Maurizio Casimirri
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: