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.pemfile 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.pemAny 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
| Option | What for |
|---|---|
tls=true | Required: the client port only accepts TLS. |
tlsCAFile | The cluster CA. Java and .NET take it from their trust store. |
authSource | The user's database, if it is not the one in the string. |
replicaSet | Only with the replica set presentation, with the name you gave it. |
readPreference | secondary or nearest read from replicas with data a few seconds old. |
w and retryWrites | As 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=trueis missing. - The driver finds no primary because the string has
replicaSetand the cluster presents itself asmongos.
See also
- Node.js, Python, Java and the other drivers of this group.
- Replica set mode