For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

Server Settings

In this guide, you can learn about how the Java driver manages server settings.

Include the following parameters in your connection string to modify the driver's behavior when interacting with the server:

Option Name
Type
Description

appName

string

Specifies the name of the application provided to MongoDB instances during the connection handshake. Can be used for server logs and profiling.

Default: null

serverMonitoringMode

string

Specifies which server monitoring protocol the driver uses. When set to auto, the monitoring mode is determined by the environment in which the driver is running. The driver uses poll mode in function-as-a-service (FaaS) environments and stream mode in other environments.

Default: auto

heartbeatFrequencyMS

integer

Specifies the frequency, in milliseconds that the driver will wait between attempts to determine the current state of each server in the cluster.

Default: 10000 (10 seconds)

This example specifies that the cluster monitor will attempt to reach a server every 15 seconds:

ConnectionString connectionString = "mongodb://<host>:<port>/?heartbeatFrequencyMS=15000"
MongoClient mongoClient = MongoClients.create(connectionString)

For more information about these parameters, see the ConnectionString API documentation.