Overview
In this guide, you can learn about MongoDB connection and authentication options. You can set connection options as parameters of your connection string to specify how your Client instance behaves while connected to the server.
Option Name | Accepted Values | Default Value | Description |
|---|---|---|---|
appName | String | None | Specifies the application name that the |
authMechanism | String | None | Specifies which authentication mechanism to use. If you do not specify this option, the driver uses the default authentication mechanism. To learn more about authentication in the Rust driver, see the guide on Authentication Mechanisms. |
authMechanismProperties | String | None | Specifies more properties for the authentication mechanism set in the |
authSource | String | See description | Specifies the database used to authenticate. |
compressors | A comma-separated list of strings | None | Specifies compressors that the |
connectTimeoutMS | Non-negative integer |
| Specifies the connection timeout, in milliseconds, passed to each underlying TCP stream when attempting to connect to the server. |
directConnection | Boolean |
| Specifies whether the |
heartbeatFrequencyMS | Integer greater than or equal to 500 |
| Specifies the amount of time in milliseconds that each monitoring thread waits between performing server checks. |
journal | Boolean |
| Requests acknowledgment that the operation propagated to the on-disk journal. |
localThresholdMS | Non-negative integer | 15 | Specifies the amount of time in milliseconds that the average
round-trip time between the driver and server can last
compared to the shortest round-trip time of all the suitable servers. |
maxIdleTimeMS | Non-negative integer |
| Specifies the amount of time in milliseconds that a connection
can remain idle in a connection pool before the server closes it. |
maxStalenessSeconds |
|
| Specifies the maximum lag, in seconds, behind the primary node
that a secondary node can be to be considered for the given operation. |
maxPoolSize | Non-negative integer |
| Specifies the maximum number of connections that the |
minPoolSize | Non-negative integer |
| Specifies the minimum number of connections that are available in
a server's connection pool at a given time. |
readConcernLevel | String | None | Specifies the default read concern for operations performed on the |
readPreference | String |
| Specifies how the driver routes a read operation to members of a replica set. To learn more, see Read Preference in the Server manual. |
readPreferenceTags | A list of comma-separated key-value pairs | None | Specifies which replica set members are considered for operations. Each instance of this key is a separate tag set. The driver checks each tag set until it finds one or more servers with each tag in the set. |
replicaSet | String | None | Specifies the name of the replica set that the |
retryReads | Boolean |
| Specifies whether the client retries a read operation if the operation fails. |
serverSelectionTimeoutMS | Non-negative integer |
| Specifies the amount of time in milliseconds that the |
tls | Boolean |
| Specifies the TLS configuration for the |
tlsAllowInvalidCertificates | Boolean |
| Specifies whether the |
tlsCAFile | String | See description | Specifies the path to the certificate authority (CA) file that
the |
tlsCertificateKeyFile | String | None | Specifies the path to the certificate file that the |
tlsInsecure | Boolean |
| Specifies whether the |
w | Non-negative integer or string | None | Requests acknowledgment that the operation has propagated to a
specific number or variety of servers. |
wTimeoutMS | Non-negative integer | No timeout | Specifies a time limit, in milliseconds, for the write concern. If an operation has not propagated to the requested level within the time limit, the driver raises an error. |
zlibCompressionLevel | Integer between -1 and 9 (inclusive) |
| Specifies the level field of the |
To see a full list of connection options, visit the Connection String Options section of the Server manual entry on Connection Strings.