Skip site navigation (1)Skip section navigation (2)

  
 
  

home | help
MONGOC_URI_T(3) 		    libmongoc			 MONGOC_URI_T(3)

SYNOPSIS
	typedef struct _mongoc_uri_t mongoc_uri_t;

DESCRIPTION
     mongoc_uri_t  provides  an abstraction on top of the MongoDB connection URI
     format. It provides standardized parsing as well as convenience methods for
     extracting useful information such as replica hosts or authorization infor-
     mation.

     See Connection String URI Reference on the MongoDB website for more  infor-
     mation.

FORMAT
	mongodb[+srv]://			     <1>
	   [username:password@] 		     <2>
	   host1				     <3>
	   [:port1]				     <4>
	   [,host2[:port2],...[,hostN[:portN]]]      <5>
	   [/[database] 			     <6>
	   [?options]]				     <7>

     1. "mongodb"  is  the  specifier of the MongoDB protocol. Use "mongodb+srv"
	with a single service name in place of "host1" to  specify  the  initial
	list of servers with an SRV record.

     2. An optional username and password.

     3. The  only  required  part of the uri.  This specifies either a hostname,
	IPv4 address, IPv6 address enclosed in	"["  and  "]",	or  UNIX  domain
	socket.

     4. An optional port number.  Defaults to :27017.

     5. Extra  optional  hosts and ports.  You would specify multiple hosts, for
	example, for connections to replica sets.

     6. The name of the database to authenticate if the  connection  string  in-
	cludes	authentication	credentials.   If /database is not specified and
	the connection string includes	credentials,  defaults	to  the  'admin'
	database.

     7. Connection specific options.

     NOTE:
	Option	names  are case-insensitive. Do not repeat the same option (e.g.
	"mongodb://localhost/db?opt=value1&OPT=value2") since this may have  un-
	expected results.

     The  MongoDB  C  Driver exposes constants for each supported connection op-
     tion. These constants make it easier to discover  connection  options,  but
     their string values can be used as well.

     For example, the following calls are equal.

	uri = mongoc_uri_new ("mongodb://localhost/?" MONGOC_URI_APPNAME "=applicationName");
	uri = mongoc_uri_new ("mongodb://localhost/?appname=applicationName");
	uri = mongoc_uri_new ("mongodb://localhost/?appName=applicationName");

REPLICA SET EXAMPLE
     To  describe  a connection to a replica set named 'test' with the following
     mongod hosts:

     * db1.example.com on port 27017

     * db2.example.com on port 2500

     You would use a connection string that resembles the following.

	mongodb://db1.example.com,db2.example.com:2500/?replicaSet=test

SRV EXAMPLE
     If  you  have  configured	an  SRV  record  with	a   name   like   "_mon-
     godb._tcp.server.example.com"  whose records are a list of one or more Mon-
     goDB server hostnames, use a connection string like this:

	uri = mongoc_uri_new ("mongodb+srv://server.example.com/?replicaSet=rs&appName=applicationName");

     The driver prefixes the service name with "_mongodb._tcp.", then performs a
     DNS SRV query to resolve the service name to one or more hostnames. If this
     query succeeds, the driver performs a DNS TXT query  on  the  service  name
     (without  the "_mongodb._tcp" prefix) for additional URI options configured
     as TXT records.

     On Unix, the MongoDB C Driver relies on libresolv to look up  SRV	and  TXT
     records.  If  libresolv is unavailable, then using a "mongodb+srv" URI will
     cause an error. If your libresolv lacks res_nsearch then  the  driver  will
     fall back to res_search, which is not thread-safe.

     Set  the  environment variable MONGOC_EXPERIMENTAL_SRV_PREFER_TCP to prefer
     TCP for the initial  queries.  The  environment  variable	is  ignored  for
     res_search.  Large  DNS responses over UDP may be truncated due to UDP size
     limitations. DNS resolvers are expected to retry over TCP if  the	UDP  re-
     sponse  indicates truncation. Some observed DNS environments do not set the
     truncation flag (TC), preventing the TCP retry. This  environment	variable
     is currently experimental and subject to change.

IPV4 AND IPV6
     If  connecting  to  a hostname that has both IPv4 and IPv6 DNS records, the
     behavior follows RFC-6555. A connection to the IPv6  address  is  attempted
     first.  If  IPv6 fails, then a connection is attempted to the IPv4 address.
     If the connection attempt to IPv6 does not complete within 250ms, then IPv4
     is tried in parallel.  Whichever  succeeds  connection  first  cancels  the
     other. The successful DNS result is cached for 10 minutes.

     As  a  consequence,  attempts to connect to a mongod only listening on IPv4
     may be delayed if there are both A (IPv4) and AAAA (IPv6) DNS records asso-
     ciated with the host.

     To avoid a delay, configure hostnames to match the  MongoDB  configuration.
     That is, only create an A record if the mongod is only listening on IPv4.

CONNECTION OPTIONS
+--------------------+------------------+------------------+-------------------------------------+
| Constant	     | Key		| Default	   | Description			 |
+--------------------+------------------+------------------+-------------------------------------+
| MON-		     | retryreads	| true		   | If   "true"  and			 |
| GOC_URI_RETRYREADS |			|		   | the server is  a			 |
|		     |			|		   | MongoDB	 3.6+			 |
|		     |			|		   | standalone,			 |
|		     |			|		   | replica set,  or			 |
|		     |			|		   | sharded cluster,			 |
|		     |			|		   | the       driver			 |
|		     |			|		   | safely retries a			 |
|		     |			|		   | read that failed			 |
|		     |			|		   | due to a network			 |
|		     |			|		   | error or replica			 |
|		     |			|		   | set failover.			 |
+--------------------+------------------+------------------+-------------------------------------+
| MONGOC_URI_RETRY-  | retrywrites	| true	if  driver | If   "true"  and			 |
| WRITES	     |			| built w/ TLS	   | the server is  a			 |
|		     |			|		   | MongoDB	 3.6+			 |
|		     |			|		   | replica  set  or			 |
|		     |			|		   | sharded cluster,			 |
|		     |			|		   | the       driver			 |
|		     |			|		   | safely retries a			 |
|		     |			|		   | write	 that			 |
|		     |			|		   | failed  due to a			 |
|		     |			|		   | network error or			 |
|		     |			|		   | replica	  set			 |
|		     |			|		   | failover.	 Only			 |
|		     |			|		   | inserts, updates			 |
|		     |			|		   | of single	docu-			 |
|		     |			|		   | ments,	   or			 |
|		     |			|		   | deletes of  sin-			 |
|		     |			|		   | gle    documents			 |
|		     |			|		   | are retried.			 |
+--------------------+------------------+------------------+-------------------------------------+
| MONGOC_URI_APPNAME | appname		| Empty  (no  app- | The  client  ap-			 |
|		     |			| name) 	   | plication	name.			 |
|		     |			|		   | This   value  is			 |
|		     |			|		   | used by  MongoDB			 |
|		     |			|		   | when   it	 logs			 |
|		     |			|		   | connection   in-			 |
|		     |			|		   | formation	  and			 |
|		     |			|		   | profile informa-			 |
|		     |			|		   | tion,  such   as			 |
|		     |			|		   | slow queries.			 |
+--------------------+------------------+------------------+-------------------------------------+
| MONGOC_URI_TLS     | tls		| Empty  (not set, | {true|false},			 |
|		     |			| same as false)   | indicating    if			 |
|		     |			|		   | TLS    must   be			 |
|		     |			|		   | used. (See  also			 |
|		     |			|		   | mongoc_client_set_ssl_opts()	 |
|		     |			|		   | and				 |
|		     |			|		   | mongoc_client_pool_set_ssl_opts().) |
+--------------------+------------------+------------------+-------------------------------------+
| MONGOC_URI_COM-    | compressors	| Empty  (no  com- | Comma separated  list  of	compres- |
| PRESSORS	     |			| pressors)	   | sors,  if	any,  to use to compress |
|		     |			|		   | the wire protocol messages. Snappy, |
|		     |			|		   | zlib, and zstd are  optional  build |
|		     |			|		   | time  dependencies,  and enable the |
|		     |			|		   | "snappy", "zlib", and "zstd" values |
|		     |			|		   | respectively.			 |
+--------------------+------------------+------------------+-------------------------------------+
| MONGOC_URI_CON-    | connecttimeoutms | 10,000  ms   (10 | This  setting applies to new server |
| NECTTIMEOUTMS      |			| seconds)	   | connections. It is also used as the |
|		     |			|		   | socket timeout for server discovery |
|		     |			|		   | and monitoring operations. 	 |
+--------------------+------------------+------------------+-------------------------------------+
| MONGOC_URI_SOCKET- | sockettimeoutms	| 300,000  ms	(5 | The time in milliseconds to attempt |
| TIMEOUTMS	     |			| minutes)	   | to  send or receive on a socket be- |
|		     |			|		   | fore the attempt times out.	 |
+--------------------+------------------+------------------+-------------------------------------+
| MONGOC_URI_REPLI-  | replicaset	| Empty (no repli- | The name of the  Replica  Set  that |
| CASET 	     |			| caset)	   | the driver should connect to.	 |
+--------------------+------------------+------------------+-------------------------------------+
| MONGOC_URI_ZLIB-   | zlibcompression- | -1		   | When the MONGOC_URI_COMPRESSORS in- |
| COMPRESSIONLEVEL   | level		|		   | cludes  "zlib" this options config- |
|		     |			|		   | ures the  zlib  compression  level, |
|		     |			|		   | when the zlib compressor is used to |
|		     |			|		   | compress client data.		 |
+--------------------+------------------+------------------+-------------------------------------+
| MONGOC_URI_LOAD-   | loadbalanced	| false 	   | If  true, this indicates the driver |
| BALANCED	     |			|		   | is connecting to a MongoDB  cluster |
|		     |			|		   | behind a load balancer.		 |
+--------------------+------------------+------------------+-------------------------------------+
| MONGOC_URI_SRVMAX- | srvmaxhosts	| 0		   | If zero, the number of hosts in DNS |
| HOSTS 	     |			|		   | results  is  unlimited.  If greater |
|		     |			|		   | than zero, the number of  hosts  in |
|		     |			|		   | DNS  results  is  limited	to being |
|		     |			|		   | less than or  equal  to  the  given |
|		     |			|		   | value.				 |
+--------------------+------------------+------------------+-------------------------------------+

     WARNING:
	Setting  any  of  the *timeoutMS options above to either 0 or a negative
	value is discouraged due to unspecified and inconsistent behavior.   The
	"default value" historically specified as a fallback for 0 or a negative
	value  is  NOT	related to the default values for the *timeoutMS options
	documented above.  The meaning of a timeout of 0 or a negative value may
	vary depending on the operation being executed, even when  specified  by
	the  same  URI	option.   To  specify the documented default value for a
	*timeoutMS option, use the MONGOC_DEFAULT_* constants  defined	in  mon-
	goc-client.h instead.

AUTHENTICATION OPTIONS
       +----------------------+----------------------+----------------------+
       | Constant	      | Key		     | Description	    |
       +----------------------+----------------------+----------------------+
       | MONGOC_URI_AUTHMECH- | authmechanism	     | Specifies the mecha- |
       | ANISM		      | 		     | nism to use when au- |
       |		      | 		     | thenticating  as the |
       |		      | 		     | provided user. See - |
       |		      | 		     | Authentication	for |
       |		      | 		     | supported values.    |
       +----------------------+----------------------+----------------------+
       | MONGOC_URI_AUTHMECH- | authmechanismproper- | Certain	authentica- |
       | ANISMPROPERTIES      | ties		     | tion mechanisms have |
       |		      | 		     | additional   options |
       |		      | 		     | that  can be config- |
       |		      | 		     | ured. These  options |
       |		      | 		     | should  be  provided |
       |		      | 		     | as  comma  separated |
       |		      | 		     | option_key:op-	    |
       |		      | 		     | tion_value  pair and |
       |		      | 		     | provided  as   auth- |
       |		      | 		     | MechanismProperties. |
       |		      | 		     | Specifying  the same |
       |		      | 		     | option_key  multiple |
       |		      | 		     | times  has undefined |
       |		      | 		     | behavior.	    |
       +----------------------+----------------------+----------------------+
       | MONGOC_URI_AUTH-     | authsource	     | The  authSource	de- |
       | SOURCE 	      | 		     | fines  the  database |
       |		      | 		     | that should be  used |
       |		      | 		     | to  authenticate to. |
       |		      | 		     | It is unnecessary to |
       |		      | 		     | provide this  option |
       |		      | 		     | the database name is |
       |		      | 		     | the   same   as	the |
       |		      | 		     | database used in the |
       |		      | 		     | URI.		    |
       +----------------------+----------------------+----------------------+

   Mechanism Properties
       +---------------------+----------------------+----------------------+
       | Constant	     | Key		    | Description	   |
       +---------------------+----------------------+----------------------+
       | MONGOC_URI_CANONI-  | canonicalizehostname | Use  the	 canonical |
       | CALIZEHOSTNAME      |			    | hostname of the ser- |
       |		     |			    | vice,   rather  than |
       |		     |			    | its	configured |
       |		     |			    | alias,  when authen- |
       |		     |			    | ticating	      with |
       |		     |			    | Cyrus-SASL Kerberos. |
       +---------------------+----------------------+----------------------+
       | MONGOC_URI_GSSAPIS- | gssapiservicename    | Use alternative ser- |
       | ERVICENAME	     |			    | vice  name.  The de- |
       |		     |			    | fault is mongodb.    |
       +---------------------+----------------------+----------------------+

TLS OPTIONS
       +----------------------+----------------------+----------------------+
       | Constant	      | Key		     | Description	    |
       +----------------------+----------------------+----------------------+
       | MONGOC_URI_TLS       | tls		     | {true|false},  indi- |
       |		      | 		     | cating  if  TLS must |
       |		      | 		     | be used. 	    |
       +----------------------+----------------------+----------------------+
       | MONGOC_URI_TLSCER-   | tlscertificatekey-   | Path to PEM  format- |
       | TIFICATEKEYFILE      | file		     | ted   Private   Key, |
       |		      | 		     | with its Public Cer- |
       |		      | 		     | tificate    concate- |
       |		      | 		     | nated at the end.    |
       +----------------------+----------------------+----------------------+
       | MONGOC_URI_TLSCER-   | tlscertificatekey-   | The   password,	 if |
       | TIFICATEKEYFILEPASS- | password	     | any, to use  to	un- |
       | WORD		      | 		     | lock  encrypted Pri- |
       |		      | 		     | vate Key.	    |
       +----------------------+----------------------+----------------------+
       | MONGOC_URI_TLSCAFILE | tlscafile	     | One, or a bundle of, |
       |		      | 		     | Certificate Authori- |
       |		      | 		     | ties whom should  be |
       |		      | 		     | considered   to	 be |
       |		      | 		     | trusted. 	    |
       +----------------------+----------------------+----------------------+
       | MONGOC_URI_TLSALLOW- | tlsallowinvalidcer-  | Accept  and   ignore |
       | INVALIDCERTIFICATES  | tificates	     | certificate  verifi- |
       |		      | 		     | cation errors  (e.g. |
       |		      | 		     | untrusted    issuer, |
       |		      | 		     | expired, etc.)	    |
       +----------------------+----------------------+----------------------+
       | MONGOC_URI_TLSALLOW- | tlsallowinvalidhost- | Ignore hostname ver- |
       | INVALIDHOSTNAMES     | names		     | ification   of	the |
       |		      | 		     | certificate    (e.g. |
       |		      | 		     | Man In  The  Middle, |
       |		      | 		     | using valid certifi- |
       |		      | 		     | cate, but issued for |
       |		      | 		     | another hostname)    |
       +----------------------+----------------------+----------------------+
       | MONGOC_URI_TLSINSE-  | tlsinsecure	     | {true|false},  indi- |
       | CURE		      | 		     | cating  if  insecure |
       |		      | 		     | TLS  options  should |
       |		      | 		     | be  used.  Currently |
       |		      | 		     | this   implies  MON- |
       |		      | 		     | GOC_URI_TLSALLOWIN-  |
       |		      | 		     | VALIDCERTIFICATES    |
       |		      | 		     | and   MONGOC_URI_TL- |
       |		      | 		     | SALLOWINVALIDHOST-   |
       |		      | 		     | NAMES.		    |
       +----------------------+----------------------+----------------------+
       | MONGOC_URI_TLSDIS-   | tlsdisablecertifi-   | {true|false},  indi- |
       | ABLECERTIFICATEREVO- | caterevocationcheck  | cates if  revocation |
       | CATIONCHECK	      | 		     | checking    (CRL   / |
       |		      | 		     | OCSP) should be dis- |
       |		      | 		     | abled.		    |
       +----------------------+----------------------+----------------------+
       | MONGOC_URI_TLSDIS-   | tlsdisableocspend-   | {true|false},  indi- |
       | ABLEOCSPEND-	      | pointcheck	     | cates  if  OCSP	re- |
       | POINTCHECK	      | 		     | sponder	  endpoints |
       |		      | 		     | should  not  be	re- |
       |		      | 		     | quested when an OCSP |
       |		      | 		     | response is not sta- |
       |		      | 		     | pled.		    |
       +----------------------+----------------------+----------------------+

     See Configuring TLS for details about these options and about building lib-
     mongoc with TLS support.

DEPRECATED SSL OPTIONS
     The following options have been deprecated and may be removed  from  future
     releases of libmongoc.
+-----------------------+------------------+-------------------+------------------+
| Constant		| Key		   | Deprecated For    | Key		  |
+-----------------------+------------------+-------------------+------------------+
| MONGOC_URI_SSL	| ssl		   | MONGOC_URI_TLS    | tls		  |
+-----------------------+------------------+-------------------+------------------+
| MON-			| sslclientcer-    | MON-	       | tlscertifi-	  |
| GOC_URI_SSLCLIENTCER- | tificatekeyfile  | GOC_URI_TLSCER-   | catekeyfile	  |
| TIFICATEKEYFILE	|		   | TIFICATEKEYFILE   |		  |
+-----------------------+------------------+-------------------+------------------+
| MON-			| sslclientcer-    | MON-	       | tlscertifi-	  |
| GOC_URI_SSLCLIENTCER- | tificatekeypass- | GOC_URI_TLSCER-   | catekeypassword  |
| TIFICATEKEYPASSWORD	| word		   | TIFICATEKEY-      |		  |
|			|		   | FILEPASSWORD      |		  |
+-----------------------+------------------+-------------------+------------------+
| MONGOC_URI_SSLCER-	| sslcertifi-	   | MON-	       | tlscafile	  |
| TIFICATEAUTHORITYFILE | cateauthority-   | GOC_URI_TLSCAFILE |		  |
|			| file		   |		       |		  |
+-----------------------+------------------+-------------------+------------------+
| MONGOC_URI_SSLALLOW-	| sslallowinvalid- | MONGOC_URI_TLSAL- | tlsallowinvalid- |
| INVALIDCERTIFICATES	| certificates	   | LOWINVALIDCER-    | certificates	  |
|			|		   | TIFICATES	       |		  |
+-----------------------+------------------+-------------------+------------------+
| MONGOC_URI_SSLALLOW-	| sslallowinvalid- | MONGOC_URI_TLSAL- | tlsallowinvalid- |
| INVALIDHOSTNAMES	| hostnames	   | LOWINVALIDHOST-   | hostnames	  |
|			|		   | NAMES	       |		  |
+-----------------------+------------------+-------------------+------------------+

SERVER DISCOVERY, MONITORING, AND SELECTION OPTIONS
     Clients  in  a mongoc_client_pool_t share a topology scanner that runs on a
     background thread. The thread wakes every heartbeatFrequencyMS (default  10
     seconds)  to  scan all MongoDB servers in parallel. Whenever an application
     operation requires a server that is not known--for example, if there is  no
     known  primary  and your application attempts an insert--the thread rescans
     all servers every half-second. In this situation the pooled client waits up
     to serverSelectionTimeoutMS (default 30 seconds) for the thread to  find  a
     server  suitable  for the operation, then returns an error with domain MON-
     GOC_ERROR_SERVER_SELECTION.

     Technically, the total time an operation may wait	while  a  pooled  client
     scans  the topology is controlled both by serverSelectionTimeoutMS and con-
     nectTimeoutMS. The longest wait occurs if the last scan begins just at  the
     end  of  the selection timeout, and a slow or down server requires the full
     connection timeout before the client gives up.

     A non-pooled client  is  single-threaded.	Every  heartbeatFrequencyMS,  it
     blocks  the  next application operation while it does a parallel scan. This
     scan takes as long as needed to check the slowest server: roughly	connect-
     TimeoutMS.  Therefore  the default heartbeatFrequencyMS for single-threaded
     clients is greater than for pooled clients: 60 seconds.

     By default, single-threaded (non-pooled) clients scan only once when an op-
     eration requires a server that is not known. If you attempt an  insert  and
     there  is	no  known  primary, the client checks all servers once trying to
     find  it,	then  succeeds	or  returns  an  error	with  domain  MONGOC_ER-
     ROR_SERVER_SELECTION. But if you set serverSelectionTryOnce to "false", the
     single-threaded client loops, checking all servers every half-second, until
     serverSelectionTimeoutMS.

     The  total  time an operation may wait for a single-threaded client to scan
     the topology is determined by connectTimeoutMS in	the  try-once  case,  or
     serverSelectionTimeoutMS  and connectTimeoutMS if serverSelectionTryOnce is
     set "false".
       +----------------------+----------------------+----------------------+
       | Constant	      | Key		     | Description	    |
       +----------------------+----------------------+----------------------+
       | MONGOC_URI_HEART-    | heartbeatfrequencyms | The interval between |
       | BEATFREQUENCYMS      | 		     | server	 monitoring |
       |		      | 		     | checks.	Defaults to |
       |		      | 		     | 10,000ms  (10   sec- |
       |		      | 		     | onds)	in   pooled |
       |		      | 		     | (multi-threaded)     |
       |		      | 		     | mode,  60,000ms	(60 |
       |		      | 		     | seconds) 	 in |
       |		      | 		     | non-pooled      mode |
       |		      | 		     | (single-threaded).   |
       +----------------------+----------------------+----------------------+
       | MONGOC_URI_SERVERSE- | serverselectiontime- | A  timeout  in  mil- |
       | LECTIONTIMEOUTMS     | outms		     | liseconds  to  block |
       |		      | 		     | for server selection |
       |		      | 		     | before  throwing  an |
       |		      | 		     | exception.  The	de- |
       |		      | 		     | fault  is  30,0000ms |
       |		      | 		     | (30 seconds).	    |
       +----------------------+----------------------+----------------------+
       | MONGOC_URI_SERVERSE- | serverselectiontry-  | If "true", the  dri- |
       | LECTIONTRYONCE       | once		     | ver scans the topol- |
       |		      | 		     | ogy exactly once af- |
       |		      | 		     | ter server selection |
       |		      | 		     | fails,  then  either |
       |		      | 		     | selects a server  or |
       |		      | 		     | returns an error. If |
       |		      | 		     | it  is  false,  then |
       |		      | 		     | the  driver  repeat- |
       |		      | 		     | edly  searches for a |
       |		      | 		     | suitable server	for |
       |		      | 		     | up  to  serverSelec- |
       |		      | 		     | tionTimeoutMS   mil- |
       |		      | 		     | liseconds (pausing a |
       |		      | 		     | half  second between |
       |		      | 		     | attempts).  The	de- |
       |		      | 		     | fault  for serverSe- |
       |		      | 		     | lectionTryOnce	 is |
       |		      | 		     | "false"	for  pooled |
       |		      | 		     | clients,   otherwise |
       |		      | 		     | "true".	     Pooled |
       |		      | 		     | clients ignore  ser- |
       |		      | 		     | verSelectionTryOnce; |
       |		      | 		     | they    signal	the |
       |		      | 		     | thread to rescan the |
       |		      | 		     | topology       every |
       |		      | 		     | half-second    until |
       |		      | 		     | serverSelectionTime- |
       |		      | 		     | outMS expires.	    |
       +----------------------+----------------------+----------------------+
       | MONGOC_URI_SOCK-     | socketcheckinter-    | Only applies to sin- |
       | ETCHECKINTERVALMS    | valms		     | gle	   threaded |
       |		      | 		     | clients. If a socket |
       |		      | 		     | has  not  been  used |
       |		      | 		     | within  this   time, |
       |		      | 		     | its   connection  is |
       |		      | 		     | checked with a quick |
       |		      | 		     | "hello" call  before |
       |		      | 		     | it  is  used  again. |
       |		      | 		     | Defaults to  5,000ms |
       |		      | 		     | (5 seconds).	    |
       +----------------------+----------------------+----------------------+
       | MONGOC_URI_DIRECT-   | directconnection     | If  "true", the dri- |
       | CONNECTION	      | 		     | ver  connects  to  a |
       |		      | 		     | single	server	di- |
       |		      | 		     | rectly and will	not |
       |		      | 		     | monitor	 additional |
       |		      | 		     | servers. 	 If |
       |		      | 		     | "false",  the driver |
       |		      | 		     | connects  based	 on |
       |		      | 		     | the   presence	and |
       |		      | 		     | value of the  repli- |
       |		      | 		     | caSet option.	    |
       +----------------------+----------------------+----------------------+

     Setting  any  of  the  *TimeoutMS options above to 0 will be interpreted as
     "use the default value".

CONNECTION POOL OPTIONS
     These options govern the behavior of a mongoc_client_pool_t. They	are  ig-
     nored by a non-pooled mongoc_client_t.
      +---------------------+--------------------+--------------------------+
      | Constant	    | Key		 | Description		    |
      +---------------------+--------------------+--------------------------+
      | MONGOC_URI_MAXPOOL- | maxpoolsize	 | The	maximum  number     |
      | SIZE		    |			 | of  clients	created     |
      | 		    |			 | by		      a     |
      | 		    |			 | mongoc_client_pool_t     |
      | 		    |			 | total (both	in  the     |
      | 		    |			 | pool   and	checked     |
      | 		    |			 | out).  The	default     |
      | 		    |			 | value  is  100. Once     |
      | 		    |			 | it	 is    reached,     |
      | 		    |			 | mongoc_client_pool_pop() |
      | 		    |			 | blocks until another     |
      | 		    |			 | thread    pushes   a     |
      | 		    |			 | client.		    |
      +---------------------+--------------------+--------------------------+
      | MONGOC_URI_MINPOOL- | minpoolsize	 | Deprecated.	 This	op- |
      | SIZE		    |			 | tion's behavior does not |
      | 		    |			 | match  its name, and its |
      | 		    |			 | actual   behavior   will |
      | 		    |			 | likely hurt performance. |
      +---------------------+--------------------+--------------------------+
      | MONGOC_URI_MAXIDLE- | maxidletimems	 | Not implemented.	    |
      | TIMEMS		    |			 |			    |
      +---------------------+--------------------+--------------------------+
      | MONGOC_URI_WAIT-    | waitqueuemultiple  | Not implemented.	    |
      | QUEUEMULTIPLE	    |			 |			    |
      +---------------------+--------------------+--------------------------+
      | MONGOC_URI_WAIT-    | waitqueuetimeoutms | The maximum time to wait |
      | QUEUETIMEOUTMS	    |			 | for	a  client to become |
      | 		    |			 | available from the pool. |
      +---------------------+--------------------+--------------------------+

WRITE CONCERN OPTIONS
	     +--------------------+------------+----------------------+
	     | Constant 	  | Key        | Description	      |
	     +--------------------+------------+----------------------+
	     | MONGOC_URI_W	  | w	       | Determines the write |
	     |			  |	       | concern (guarantee). |
	     |			  |	       | Valid values:	      |
	     |			  |	       |		      |
	     |			  |	       |      * 0 = The  dri- |
	     |			  |	       |	ver  will not |
	     |			  |	       |	acknowledge   |
	     |			  |	       |	write  opera- |
	     |			  |	       |	tions	  but |
	     |			  |	       |	will pass  or |
	     |			  |	       |	handle	  any |
	     |			  |	       |	network   and |
	     |			  |	       |	socket errors |
	     |			  |	       |	that  it  re- |
	     |			  |	       |	ceives to the |
	     |			  |	       |	client.    If |
	     |			  |	       |	you   disable |
	     |			  |	       |	write concern |
	     |			  |	       |	but    enable |
	     |			  |	       |	the	 get- |
	     |			  |	       |	LastError     |
	     |			  |	       |	commandas   w |
	     |			  |	       |	option,     w |
	     |			  |	       |	overrides the |
	     |			  |	       |	w option.     |
	     |			  |	       |		      |
	     |			  |	       |      * 1 =  Provides |
	     |			  |	       |	basic	  ac- |
	     |			  |	       |	knowledgement |
	     |			  |	       |	of write  op- |
	     |			  |	       |	erations.  By |
	     |			  |	       |	specifying 1, |
	     |			  |	       |	you   require |
	     |			  |	       |	that a stand- |
	     |			  |	       |	alone  mongod |
	     |			  |	       |	instance,  or |
	     |			  |	       |	the   primary |
	     |			  |	       |	for   replica |
	     |			  |	       |	sets,	  ac- |
	     |			  |	       |	knowledge all |
	     |			  |	       |	write  opera- |
	     |			  |	       |	tions.	  For |
	     |			  |	       |	drivers   re- |
	     |			  |	       |	leased	after |
	     |			  |	       |	the   default |
	     |			  |	       |	write concern |
	     |			  |	       |	change,  this |
	     |			  |	       |	is  the   de- |
	     |			  |	       |	fault	write |
	     |			  |	       |	concern  set- |
	     |			  |	       |	ting.	      |
	     |			  |	       |		      |
	     |			  |	       |      * majority    = |
	     |			  |	       |	For   replica |
	     |			  |	       |	sets,  if you |
	     |			  |	       |	specify   the |
	     |			  |	       |	special   ma- |
	     |			  |	       |	jority	value |
	     |			  |	       |	to  w option, |
	     |			  |	       |	write  opera- |
	     |			  |	       |	tions	 will |
	     |			  |	       |	only   return |
	     |			  |	       |	successfully  |
	     |			  |	       |	after  a  ma- |
	     |			  |	       |	jority of the |
	     |			  |	       |	configured    |
	     |			  |	       |	replica   set |
	     |			  |	       |	members  have |
	     |			  |	       |	acknowledged  |
	     |			  |	       |	the write op- |
	     |			  |	       |	eration.      |
	     |			  |	       |		      |
	     |			  |	       |      * n    =	  For |
	     |			  |	       |	replica sets, |
	     |			  |	       |	if  you spec- |
	     |			  |	       |	ify a  number |
	     |			  |	       |	n     greater |
	     |			  |	       |	than 1, oper- |
	     |			  |	       |	ations	 with |
	     |			  |	       |	this	write |
	     |			  |	       |	concern   re- |
	     |			  |	       |	turn only af- |
	     |			  |	       |	ter n members |
	     |			  |	       |	of   the  set |
	     |			  |	       |	have acknowl- |
	     |			  |	       |	edged	  the |
	     |			  |	       |	write. If you |
	     |			  |	       |	set  n	to  a |
	     |			  |	       |	number	 that |
	     |			  |	       |	is    greater |
	     |			  |	       |	than the num- |
	     |			  |	       |	ber of avail- |
	     |			  |	       |	able set mem- |
	     |			  |	       |	bers or  mem- |
	     |			  |	       |	bers	 that |
	     |			  |	       |	hold	data, |
	     |			  |	       |	MongoDB  will |
	     |			  |	       |	wait,  poten- |
	     |			  |	       |	tially indef- |
	     |			  |	       |	initely,  for |
	     |			  |	       |	these members |
	     |			  |	       |	to     become |
	     |			  |	       |	available.    |
	     |			  |	       |		      |
	     |			  |	       |      * tags   =  For |
	     |			  |	       |	replica sets, |
	     |			  |	       |	you can spec- |
	     |			  |	       |	ify a tag set |
	     |			  |	       |	to    require |
	     |			  |	       |	that all mem- |
	     |			  |	       |	bers  of  the |
	     |			  |	       |	set that have |
	     |			  |	       |	these	 tags |
	     |			  |	       |	configured    |
	     |			  |	       |	return	 con- |
	     |			  |	       |	firmation  of |
	     |			  |	       |	the write op- |
	     |			  |	       |	eration.      |
	     +--------------------+------------+----------------------+
	     | MONGOC_URI_WTIME-  | wtimeoutms | The   time  in  mil- |
	     | OUTMS		  |	       | liseconds  to	 wait |
	     |			  |	       | for  replication  to |
	     |			  |	       | succeed,  as  speci- |
	     |			  |	       | fied  in  the	w op- |
	     |			  |	       | tion, before  timing |
	     |			  |	       | out. When wtimeoutMS |
	     |			  |	       | is  0,  write opera- |
	     |			  |	       | tions	 will	never |
	     |			  |	       | time out.	      |
	     +--------------------+------------+----------------------+
	     | MONGOC_URI_JOURNAL | journal    | Controls     whether |
	     |			  |	       | write	   operations |
	     |			  |	       | will  wait until the |
	     |			  |	       | mongod  acknowledges |
	     |			  |	       | the write operations |
	     |			  |	       | and commits the data |
	     |			  |	       | to the on disk jour- |
	     |			  |	       | nal.		      |
	     |			  |	       |		      |
	     |			  |	       |      * true   =  En- |
	     |			  |	       |	ables journal |
	     |			  |	       |	commit	  ac- |
	     |			  |	       |	knowledgement |
	     |			  |	       |	write	 con- |
	     |			  |	       |	cern. Equiva- |
	     |			  |	       |	lent to spec- |
	     |			  |	       |	ifying	  the |
	     |			  |	       |	getLastError  |
	     |			  |	       |	command  with |
	     |			  |	       |	the j  option |
	     |			  |	       |	enabled.      |
	     |			  |	       |		      |
	     |			  |	       |      * false  = Does |
	     |			  |	       |	not   require |
	     |			  |	       |	that   mongod |
	     |			  |	       |	commit	write |
	     |			  |	       |	operations to |
	     |			  |	       |	the   journal |
	     |			  |	       |	before	  ac- |
	     |			  |	       |	knowledging   |
	     |			  |	       |	the write op- |
	     |			  |	       |	eration. This |
	     |			  |	       |	is   the  de- |
	     |			  |	       |	fault  option |
	     |			  |	       |	for the jour- |
	     |			  |	       |	nal   parame- |
	     |			  |	       |	ter.	      |
	     +--------------------+------------+----------------------+

READ CONCERN OPTIONS
	 +---------------------+------------------+----------------------+
	 | Constant	       | Key		  | Description 	 |
	 +---------------------+------------------+----------------------+
	 | MONGOC_URI_READCON- | readconcernlevel | The level of  isola- |
	 | CERNLEVEL	       |		  | tion for read opera- |
	 |		       |		  | tions.  If the level |
	 |		       |		  | is left unspecified, |
	 |		       |		  | the  server  default |
	 |		       |		  | will  be used. See - |
	 |		       |		  | readConcern  in  the |
	 |		       |		  | MongoDB  Manual  for |
	 |		       |		  | details.		 |
	 +---------------------+------------------+----------------------+

READ PREFERENCE OPTIONS
     When connected to a replica set, the driver chooses which member  to  query
     using the read preference:

     1. Choose members whose type matches "readPreference".

     2. From these, if there are any tags sets configured, choose members match-
	ing  the first tag set. If there are none, fall back to the next tag set
	and so on, until some members are chosen or the tag sets are exhausted.

     3. From the chosen servers, distribute queries randomly  among  the  server
	with  the  fastest  round-trip	times. These include the server with the
	fastest time and any whose round-trip time is no more than "localThresh-
	oldMS" slower.
       +----------------------+---------------------+----------------------+
       | Constant	      | Key		    | Description	   |
       +----------------------+---------------------+----------------------+
       | MONGOC_URI_READPREF- | readpreference	    | Specifies        the |
       | ERENCE 	      | 		    | replica	set   read |
       |		      | 		    | preference for  this |
       |		      | 		    | connection.     This |
       |		      | 		    | setting	 overrides |
       |		      | 		    | any      secondaryOk |
       |		      | 		    | value.   The    read |
       |		      | 		    | preference    values |
       |		      | 		    | are the following:   |
       |		      | 		    |			   |
       |		      | 		    |	   * primary  (de- |
       |		      | 		    |	     fault)	   |
       |		      | 		    |			   |
       |		      | 		    |	   * primaryPre-   |
       |		      | 		    |	     ferred	   |
       |		      | 		    |			   |
       |		      | 		    |	   * secondary	   |
       |		      | 		    |			   |
       |		      | 		    |	   * secondaryPre- |
       |		      | 		    |	     ferred	   |
       |		      | 		    |			   |
       |		      | 		    |	   * nearest	   |
       +----------------------+---------------------+----------------------+
       | MONGOC_URI_READPREF- | readpreferencetags  | A  representation of |
       | ERENCETAGS	      | 		    | a tag set. See  also |
       |		      | 		    | Tag Sets. 	   |
       +----------------------+---------------------+----------------------+
       | MONGOC_URI_LO-       | localthresholdms    | How  far to distrib- |
       | CALTHRESHOLDMS       | 		    | ute queries,  beyond |
       |		      | 		    | the  server with the |
       |		      | 		    | fastest	round-trip |
       |		      | 		    | time.   By  default, |
       |		      | 		    | only servers  within |
       |		      | 		    | 15ms  of the fastest |
       |		      | 		    | round-trip time  re- |
       |		      | 		    | ceive queries.	   |
       +----------------------+---------------------+----------------------+
       | MONGOC_URI_MAXSTALE- | maxstalenessseconds | The maximum replica- |
       | NESSSECONDS	      | 		    | tion  lag,  in  wall |
       |		      | 		    | clock time,  that  a |
       |		      | 		    | secondary can suffer |
       |		      | 		    | and  still be eligi- |
       |		      | 		    | ble.  The   smallest |
       |		      | 		    | allowed	value  for |
       |		      | 		    | maxStalenessSeconds  |
       |		      | 		    | is 90 seconds.	   |
       +----------------------+---------------------+----------------------+

     NOTE:
	When connecting to more than one  mongos,  libmongoc's	localThresholdMS
	applies  only  to the selection of mongos servers. The threshold for se-
	lecting among replica set members in  shards  is  controlled  by  the  -
	mongos's localThreshold command line option.

LEGACY OPTIONS
     For  historical  reasons,	the following options are available. They should
     however not be used.
		 +-----------------+------+----------------------+
		 | Constant	   | Key  | Description 	 |
		 +-----------------+------+----------------------+
		 | MONGOC_URI_SAFE | safe | {true|false} Same as |
		 |		   |	  | w={1|0}		 |
		 +-----------------+------+----------------------+

AUTHOR
     MongoDB, Inc

COPYRIGHT
     2009-present, MongoDB, Inc.

1.30.8				  Aug 27, 2026			 MONGOC_URI_T(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=mongoc_uri_t&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>

home | help