0

How to ensure with a connection string that I always connect to secondary node? Is it even possible to force a connection to a secondary node with connection string?

Quijote
  • 113
  • 1
  • 2
  • 6
  • What do you want to achieve by this? Usually MongoDB client takes care to connect to the Mongo node with the lowest latency. – noam Aug 19 '20 at 15:40

1 Answers1

0

With MongoDB writes will always go to primary and you can't do anything. Config and mongos will communicate among themselves will redirect to primary. The default value for read preference is primary, which sends all read operations to the replica set’s primary.

The read preference values are the following:

primary primaryPreferred secondary secondaryPreferred nearest For descriptions of each value, see Read Preference Modes.

Is there a specific reason you want to connect to secondary node?

Divyani Singh
  • 491
  • 8
  • 16