Connecting to MongoDB
Principle
The connect dialog can be used to create a MongoClient instance connected to a MongoDB single instance, replica set, or sharded cluster.
Several MongoClient instances can be connected and managed by UMongo.
Options
The following options are supported:
- URI: the MongoDB URI like 'mongodb://...'. See specifications at http://docs.mongodb.org/manual/reference/connection-string/
- Servers: Comma separated list of servers to connect to. Typically a single mongod or mongos server is required.
- Connection Mode: the default is "Automatic" and should be used for a replica set or a sharded cluster. The "Direct" mode is used to connect directly to a single server.
- Databases: Optional, a comma separated list of databases to use. If empty, all databases will be detected.
- User: Optional, the user name for authentication. The authentication will be used for either the provided databases or 'admin'.
- Password: Optional, the password for authentication
Advanced options
The following options are supported:
- socketType: type of socket to use. Currently 'Plain', 'SSL' and 'SSL no validation' are supported
- connectTimeout: Timeout for the socket connect operation
- socketTimeout: Timeout for the socket read/write operations
- safeWrites: Sets the global WriteConcern as SAFE, which means that writes are acknowledged by the server
- secondaryReads: Allows the read operations to go to secondary servers
Proxy options
The following options are supported:
- proxyType: Type of proxy. Currently 'None' and 'SOCKS' are supported
- proxyHost: The proxy host
- proxyPort: The proxy port
If MongoDB is not accessible from your local machine, but you can SSH to a server that can connect, do the following:
- create a SOCKS proxy from your terminal by using 'ssh -D LocalPort hostWithDBAccess -N'. An example port is 9000
- when connecting, set proxyType to 'SOCKS', proxyHost to 'localhost' and proxyPort to 9000.
Examples
Following are possible connections:
- To connect to a replica set: input at least one server name in "servers", select "automatic" connection mode
- To connect to a secondary server: input the server name in "servers", select "direct" connection mode, check "secondary reads" box