Connection string and options

What the TeselaDB connection string carries and which driver options matter.

Write the connection string of your application. It is MongoDB's, with TLS always on.

Requirements

  • The address of one or more nodes of the cluster.
  • A user with its password and the pki/ca.pem file of the cluster.

The shape of the string

mongodb://user:<password>@node-01:27017,node-02:27017,node-03:27017/shop?tls=true&tlsCAFile=./ca.pem

Any node takes each request to the range it touches, so one is enough. Put two or three so the driver has somewhere to go if one does not answer.

Options that matter

OptionWhat for
tls=trueRequired: the client port only accepts TLS.
tlsCAFileThe cluster CA. Java and .NET take it from their trust store.
authSourceThe user's database, if it is not the one in the string.
replicaSetOnly with the replica set presentation, with the name you gave it.
readPreferencesecondary or nearest read from replicas with data a few seconds old.
w and retryWritesAs in MongoDB; retryable writes are on.

Check

If you pass the string to mongosh, it opens a session against the cluster, and inside that session db.runCommand({ ping: 1 }) returns { ok: 1 }.

Common problems

  • The connection closes before authenticating because tls=true is missing.
  • The driver finds no primary because the string has replicaSet and the cluster presents itself as mongos.

See also