0

Presently MongoDB driver has this Deprecation Warning:

Current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version

when the options are set to:

const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: false });

And if I still continue with the same I get some topology error when I get the network loss, and stack-up of requests

I know the cure is to keep the useUnifiedTopology true, but I need my Server to reconnect to DB in case of network loss. Else I have to reconnect to DB for every 1or2 operations

Rishav Bhowmik
  • 57
  • 1
  • 11

2 Answers2

0

Although I am unable to find a definitive description of what useUnifiedTopology option does, what I am under the impression it does beyond the aspects mentioned in the release announcement is it makes the node driver compliant with the cross-driver specifications in various aspects of server discovery, monitoring and selection.

What this means for the current question is the node driver with useUnifiedTopology set to true is supposed to automatically monitor the deployment "correctly" (as defined in various driver specifications), reconnect when connections are lost, etc.

I know the cure is to keep the useUnifiedTopology true, but I need my Server to reconnect to DB in case of network loss. Else I have to reconnect to DB for every 1or2 operations

I would say you are either using an old/buggy version of the driver or you are doing something wrong in your application.

See also Warning on Connecting to MongoDB with a Node server.

D. SM
  • 13,584
  • 3
  • 12
  • 21
  • Actually, this document of MongoDB says otherwise. Quoting the last Paragraph of the doc `The unified topology completely removes the disconnect handler, in favor of the more robust and consistent Retryable Reads and Retryable Writes features` – Rishav Bhowmik Aug 13 '20 at 04:52
  • Thanks, that is definitely the best description I've seen to date. – D. SM Aug 13 '20 at 04:59
  • I think you are also implying that that document contradicts something I've said, which - again, in my understanding of things - in practice is not the case, contrary to what the referenced document might lead one to believe. – D. SM Aug 13 '20 at 05:05
  • So what I suggest you do is 1) use unified topology, 2) if you have a problem create a new question that clearly describes the problem. – D. SM Aug 13 '20 at 05:06
0

Did you notice that when you use the unified Yopology to true you use two connections instead of two? what means that mongodb cluster tiers cons are reduced to half of what it says?

ie. If M10 offers you 1500 cons, with ut to true you just could have active users...

Emma
  • 3
  • 2