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

ECONNREFUSED when setting autoEncryption and trying to connect to local server

    • 1
    • Not Needed
    • Not Needed

      What problem are you facing?

      I am following the official document at https://www.mongodb.com/docs/manual/core/csfle/tutorials/aws/aws-automatic/ (which is not compatible with the latest client version...).

      I was able to create the data key, but when trying to connect to mongo I am getting cryptic error:

       

      ```

      const timeoutError = new MongoServerSelectionError(
                                   ^
      MongoServerSelectionError: connect ECONNREFUSED ::1:27020
          at Timeout._onTimeout (/Users/omerlh/dev/stripe-event-handler/node_modules/mongodb/src/sdam/topology.ts:591:30)
          at listOnTimeout (node:internal/timers:564:17)
          at processTimers (node:internal/timers:507:7) {
        reason: TopologyDescription

      {     type: 'Unknown',     servers: Map(1) \{ 'localhost:27020' => [ServerDescription] }

      ,
          stale: false,
          compatible: true,
          heartbeatFrequencyMS: 10000,
          localThresholdMS: 15,
          setName: null,
          maxElectionId: null,
          maxSetVersion: null,
          commonWireVersion: 0,
          logicalSessionTimeoutMinutes: null
        },
        code: undefined,
        [Symbol(errorLabels)]: Set(0) {}
      }

      ```

      The client works and connects with no issues when `autoEncryption` is not specified.

       

      This is my code:

      ```
      const credentialsProvider = fromNodeProviderChain();

      constcredentials = awaitcredentialsProvider();
      returnMongoClient.connect(`${uri}/${dbName}`, {
      autoEncryption: {
      keyVaultNamespace,
      kmsProviders: {
      aws:

      { accessKeyId:credentials.accessKeyId, secretAccessKey:credentials.secretAccessKey, sessionToken:credentials.sessionToken, }

      ,
      },
      schemaMap: {
      // eslint-disable-next-line @typescript-eslint/naming-convention
      'db.data': {
      bsonType:'object',
      encryptMetadata:

      { keyId: [newBinary(Buffer.from(dataKey, 'base64'), 4)], }

      ,
      properties: {
      someKey: {
      bsonType:'string',
      properties: {
      policyNumber: {
      encrypt:

      { bsonType:'int', algorithm:'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic', }

      ,
      },
      },
      },
      },
      },
      },
      },
      });
      ```

      What driver and relevant dependency versions are you using?

      Driver - 4.11.0
      mongodb-client-encryption - 2.3.0
      server - latest one installed by brew

      Steps to reproduce?

       

      See above

            Assignee:
            bailey.pearson@mongodb.com Bailey Pearson
            Reporter:
            omer@goledge.com Omer Levi Hevroni
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: