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

Queries not responding with useUnifiedTopology and autoEncryption

    • Not Needed

      Hey,

      we are using mongoDb for a while and want to use CSFLE to encrypt sensitive data. I having some problems implementing a prototype. After connecting to the mongodb and the mongocryptd process a few queries are successful but after a while the queries stop responding. We are using following setup:

      • MongdDb Atlas Replica Set 4.2
      • mongoDb node driver 3.6.2

      • mongodb-client-encryption lib 1.1.0

      I can reproduce this behavior quite easily with a simple node script and the problem is connection when using autoEncryption and useUnifiedTopology together. When setting useUnifiedTopology to false the queries work correctly. Also increasing the connection pool limit helps but I dont really get why this is only relevant when using the useUnifiedTopology option.

      Here is the script I wrote (you have to replace the connection options) 

      const MongoClient = require("mongodb").MongoClient;
      
      function getData(db, collectionName, counter) {  
        console.log(`Start fetching ${collectionName} ${counter} `);  
        return db.collection(collectionName).find({}).toArray().then((data) =>       console.log(`${collectionName} ${counter}: ${data.length}`)
        );
      }
      
      async function run() {  
        const client = await MongoClient.connect(
        "mongodb://localhost:27017/gastromatic_develop",    
        {
          useNewUrlParser: true,
          useUnifiedTopology: false,
          autoEncryption: {
            keyVaultNamespace: "encryption.__keyVault",        
            kmsProviders: {...},
            extraOptions: {
              mongocryptdBypassSpawn: true,
              mongocryptdURI: "mongodb://%2Ftmp%2Fmongocryptd.sock",
            },
           },    
        });
        const db = client.db();  
        const counter = 20;
        const promises = [];
        for (let i = 0; i < counter; i++) {
           promises.push(getData(db, "Employees", i + 1));  
        }  
        await Promise.all(promises);
      }
      
      run()
        .catch((err) => console.error(err))
        .then(() => {    
          console.log("Finished");    
          process.exit()  
        });
      
      

      Maybe I just misconfigured smething here but I followed the instruction quite close. Would really appreciatesme help here.

      Best regards

      Peter

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            p.macherey@gastromatic.de Peter Macherey
            Votes:
            3 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: