@@ -55,13 +55,13 @@ The components of this string are:
55
55
56
56
- Required. It identifies a server
57
57
address to connect to. It identifies either a hostname, IP
58
- address, or UNIX domain socket.
59
-
58
+ address, or UNIX domain socket.
59
+
60
60
.. include:: /includes/fact-uri-rs-hostnames.rst
61
61
62
62
For a sharded cluster, specify the hostname of the
63
63
:binary:`~bin.mongos` instance.
64
-
64
+
65
65
66
66
* - ``:port1``
67
67
@@ -153,7 +153,7 @@ DNS SRV record. The driver or :binary:`~bin.mongo` shell will then
153
153
query the DNS for the record to determine which hosts are running the
154
154
:binary:`~bin.mongod` instances.
155
155
156
- .. note::
156
+ .. note::
157
157
158
158
Use of the ``+srv`` connection string modifier
159
159
automatically sets the ``ssl`` option to ``true`` for the connection.
@@ -164,9 +164,9 @@ The following example shows a typical connection string for a DNS
164
164
seedlist connection string:
165
165
166
166
.. code-block:: none
167
-
167
+
168
168
mongodb+srv://server.example.com/
169
-
169
+
170
170
The corresponding DNS configuration might resemble:
171
171
172
172
.. code-block:: none
@@ -181,7 +181,7 @@ The corresponding DNS configuration might resemble:
181
181
domain (in this example, ``example.com``) as the given hostname. If
182
182
the parent domains and hostname do not match, you will not be able to
183
183
connect.
184
-
184
+
185
185
Like the standard connection string, the DNS seedlist connection string
186
186
supports specifying options as a query string. With a DNS seedlist
187
187
connection string, you can *also* specify the following options via a
@@ -217,14 +217,14 @@ of the DNS entry above.
217
217
.. code-block:: none
218
218
219
219
mongodb+srv://server.example.com/?connectTimeoutMS=300000&authSource=aDifferentAuthDB
220
-
220
+
221
221
Given the override for the ``authSource``, the equivalent connection
222
222
string in the standard format would be:
223
223
224
224
.. code-block:: none
225
225
226
226
mongodb://mongodb1.example.com:27317,mongodb2.example.com:27017/?connectTimeoutMS=300000&replicaSet=mySet&authSource=aDifferentAuthDB
227
-
227
+
228
228
.. note::
229
229
The ``mongodb+srv`` option will fail if there is no available DNS
230
230
with records that correspond to the hostname identified in the
@@ -323,12 +323,74 @@ Connection Options
323
323
timeout, though different drivers might vary. See the
324
324
:ecosystem:`driver </drivers>` documentation.
325
325
326
+ * - .. urioption:: compressors
327
+
328
+ - Comma-delimited string of compressors to enable
329
+ network compression for communication between this
330
+ client and:
331
+
332
+ - a :binary:`~bin.mongod` instance
333
+
334
+ - a :binary:`~bin.mongos` instance.
335
+
336
+ You can specify the following compressors:
337
+
338
+ - :term:`snappy`
339
+
340
+ - :term:`zlib` (Available in MongoDB 3.6 or greater)
341
+
342
+ If you specify multiple compressors, then the order in which you list
343
+ the compressors matter as well as the communication initiator. For
344
+ example, if the client specifies the following network
345
+ compressors ``"zlib,snappy"`` and the :binary:`~bin.mongod` specifies
346
+ ``"snappy,zlib"``, messages between the client and the
347
+ :binary:`~bin.mongod` uses ``zlib``.
348
+
349
+ .. important::
350
+
351
+ Messages are compressed when both parties enable network
352
+ compression. Otherwise, messages between the parties are
353
+ uncompressed.
354
+
355
+ If the parties do not share at least one common compressor,
356
+ messages between the parties are uncompressed.
357
+
358
+
359
+ * - .. urioption:: zlibCompressionLevel
360
+
361
+ - An integer that specifies the compression level if using
362
+ :term:`zlib` for :urioption:`network compression <compressors>`.
363
+
364
+ You can specify an integer value ranging from ``-1`` to ``9``:
365
+
366
+ .. list-table::
367
+ :header-rows: 1
368
+ :widths: 25 75
369
+
370
+ * - Value
371
+ - Notes
372
+
373
+ * - ``-1``
374
+
375
+ - Default compression level, usually level ``6`` compression.
376
+
377
+ * - ``0``
378
+ - No compression
379
+
380
+ * - ``1`` - ``9``
381
+
382
+ - Increasing level of compression but at the cost of speed, with:
383
+
384
+ - ``1`` providing the best speed but least compression, and
385
+
386
+ - ``9`` providing the best compression but at the slowest speed.
387
+
326
388
.. _connection-pool-options:
327
389
328
390
Connection Pool Options
329
391
~~~~~~~~~~~~~~~~~~~~~~~
330
392
331
- Most drivers implement some kind of connection pool handling.
393
+ Most drivers implement some kind of connection pool handling.
332
394
Some drivers do not support connection
333
395
pools. See your :ecosystem:`driver </drivers>` documentation
334
396
for more information on the connection pooling implementation. These
@@ -460,7 +522,7 @@ isolation for their reads from replica sets.
460
522
* - .. urioption:: readConcernLevel
461
523
462
524
- The level of isolation. Can accept one of the following values:
463
-
525
+
464
526
- :readconcern:`local <"local">`
465
527
- :readconcern:`majority <"majority">`
466
528
- :readconcern:`linearizable <"linearizable">`
@@ -488,8 +550,8 @@ on a per-connection basis in the connection string:
488
550
* - .. urioption:: readPreference
489
551
490
552
- Specifies the :term:`replica set` read preference for this
491
- connection.
492
-
553
+ connection.
554
+
493
555
The read preference values are the following:
494
556
495
557
- :readmode:`primary`
@@ -507,33 +569,33 @@ on a per-connection basis in the connection string:
507
569
.. include:: /includes/extracts/transactions-read-pref.rst
508
570
509
571
* - .. urioption:: maxStalenessSeconds
510
-
572
+
511
573
- .. versionadded:: 3.4
512
-
574
+
513
575
Specifies, in seconds, how stale a secondary can be before the client
514
576
stops using it for read operations. For details, see:
515
577
:ref:`replica-set-read-preference-max-staleness`.
516
578
517
579
By default, there is no maximum staleness and clients will not consider a
518
580
secondary's lag when choosing where to direct a read operation.
519
-
581
+
520
582
The minimum :urioption:`maxStalenessSeconds` value is 90
521
583
seconds. Specifying a value between 0 and 90 seconds will produce
522
584
an error. MongoDB drivers treat a ``maxStalenessSeconds`` value
523
585
of ``-1`` as "no max staleness", the same as if
524
586
``maxStalenessSeconds`` is omitted.
525
-
587
+
526
588
.. important::
527
589
To use ``maxStalenessSeconds``, all of the
528
590
MongoDB instances in your deployment must be using MongoDB 3.4 or
529
591
later. If any instances are on an earlier version of MongoDB, the
530
592
driver or :binary:`~bin.mongos` will raise an error.
531
-
593
+
532
594
The following specifies a maxStalenessSeconds value of 120 seconds
533
595
with the :readmode:`secondary` read preference mode:
534
-
596
+
535
597
.. code-block:: none
536
-
598
+
537
599
mongodb://host.example.com/?readPreference=secondary&maxStalenessSeconds=120
538
600
539
601
* - .. urioption:: readPreferenceTags
@@ -615,30 +677,30 @@ Authentication Options
615
677
* - .. urioption:: authMechanismProperties
616
678
617
679
- Specify properties for the specified :urioption:`authMechanism`
618
- as a comma-separated list of colon-separated key-value pairs.
619
- For example:
680
+ as a comma-separated list of colon-separated key-value pairs.
681
+ For example:
620
682
621
683
.. code-block:: shell
622
684
:copyable: false
623
685
624
686
authMechanismProperties=SERVICE_NAME:mongodb,CANONICALIZE_HOST_NAME:true
625
687
626
- The :urioption:`authMechanismProperties` option is only supported
627
- when :urioption:`authMechanism` is
688
+ The :urioption:`authMechanismProperties` option is only supported
689
+ when :urioption:`authMechanism` is
628
690
:ref:`GSSAPI <security-auth-kerberos>`. Possible values are:
629
691
630
692
``SERVICE_NAME:<string>``
631
693
Set the Kerberos service name when connecting to Kerberized
632
694
MongoDB instances. This value must match the service name set
633
- on MongoDB instances to which you are connecting.
695
+ on MongoDB instances to which you are connecting.
634
696
635
- ``SERVICE_NAME`` defaults to ``mongodb`` for all clients and
697
+ ``SERVICE_NAME`` defaults to ``mongodb`` for all clients and
636
698
MongoDB instances. If you change the
637
699
:parameter:`saslServiceName` setting on a MongoDB instance, you
638
700
must set ``SERVICE_NAME`` to match that setting.
639
701
640
702
``CANONICALIZE_HOST_NAME:true|false``
641
- Canonicalize the hostname of the client host machine when
703
+ Canonicalize the hostname of the client host machine when
642
704
connecting to the Kerberos server. This may be required when
643
705
hosts report different hostnames than what is in the Kerberos
644
706
database. Defaults to ``false``.
@@ -660,10 +722,10 @@ Authentication Options
660
722
must set :urioption:`gssapiServiceName` to match that setting.
661
723
662
724
:urioption:`gssapiServiceName` is a deprecated aliases for
663
- :urioption:`authMechanismProperties=SERVICE_NAME:mongodb
664
- <authMechanismProperties>`. For more information on which
665
- options your driver supports and their relative priority to each
666
- other, reference the documentation for your preferred driver
725
+ :urioption:`authMechanismProperties=SERVICE_NAME:mongodb
726
+ <authMechanismProperties>`. For more information on which
727
+ options your driver supports and their relative priority to each
728
+ other, reference the documentation for your preferred driver
667
729
version.
668
730
669
731
.. _selection-discovery-options:
@@ -678,16 +740,16 @@ or write operations.
678
740
.. list-table::
679
741
:header-rows: 1
680
742
:widths: 30 70
681
-
743
+
682
744
* - Connection Option
683
745
- Description
684
-
746
+
685
747
* - .. urioption:: localThresholdMS
686
748
687
749
- The size (in milliseconds) of the latency window for selecting
688
750
among multiple suitable MongoDB instances. *Default*: 15
689
751
milliseconds.
690
-
752
+
691
753
All drivers use :urioption:`localThresholdMS`. Use the
692
754
``localThreshold`` alias when specifying the latency window size
693
755
to :binary:`~bin.mongos`.
@@ -706,7 +768,7 @@ or write operations.
706
768
error. When ``false``, the driver blocks and searches for a
707
769
server up to the :urioption:`serverSelectionTimeoutMS` value.
708
770
*Default*: ``true``.
709
-
771
+
710
772
Multi-threaded drivers and :binary:`~bin.mongos` do not support
711
773
:urioption:`serverSelectionTryOnce`.
712
774
@@ -716,13 +778,13 @@ or write operations.
716
778
checks the state of the MongoDB deployment. Specify the interval
717
779
(in milliseconds) between checks, counted from the end of the
718
780
previous check until the beginning of the next one.
719
-
781
+
720
782
*Default*:
721
-
783
+
722
784
- Single-threaded drivers: 60 seconds.
723
785
- Multi-threaded drivers: 10 seconds.
724
-
725
- :binary:`~bin.mongos` does not support changing the frequency of
786
+
787
+ :binary:`~bin.mongos` does not support changing the frequency of
726
788
the heartbeat checks.
727
789
728
790
Miscellaneous Configuration
@@ -736,23 +798,23 @@ Miscellaneous Configuration
736
798
- Description
737
799
738
800
* - .. urioption:: appName
739
-
740
- - Specify a custom app name. The app name appears in
741
-
801
+
802
+ - Specify a custom app name. The app name appears in
803
+
742
804
- :binary:`~bin.mongod` and :binary:`~bin.mongos` :doc:`logs
743
805
</reference/log-messages>`,
744
806
745
807
- the :data:`currentOp.appName` field in the :dbcommand:`currentOp`
746
808
command and :method:`db.currentOp()` method output,
747
-
809
+
748
810
- the :data:`system.profile.appName` field in the :doc:`database
749
811
profiler </reference/database-profiler>` output.
750
-
812
+
751
813
If you do not specify a custom app name, the :binary:`~bin.mongo`
752
814
shell uses the default "``MongoDB Shell``".
753
-
815
+
754
816
.. versionadded:: 4.0
755
-
817
+
756
818
* - .. urioption:: retryWrites
757
819
758
820
- Enable :ref:`retryable writes <retryable-writes>`.
@@ -830,7 +892,7 @@ UNIX Domain Socket
830
892
~~~~~~~~~~~~~~~~~~
831
893
832
894
Use a URL encoded connection string when connecting to a UNIX domain
833
- socket.
895
+ socket.
834
896
835
897
The following connects to a UNIX domain socket with file path
836
898
``/tmp/mongodb-27017.sock``:
0 commit comments