Skip to content

Commit 13c1db0

Browse files
skerschbkay-kim
authored andcommitted
DOCS-10980 incorporated changes to mongodb.com references
updates per changes to the spec
1 parent ab5dc1e commit 13c1db0

File tree

2 files changed

+43
-25
lines changed

2 files changed

+43
-25
lines changed

source/includes/options-mongo.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,19 @@ description: |
7474
If the hostname does not match the CN/SAN, {{program}} will fail to
7575
connect.
7676
77-
For DNS seedlist connections, specify the connection protocol as
78-
``mongodb+srv:", followed by the DNS SRV hostname record and any
79-
options for overriding DNS TXT configured options. For example:
77+
For `DNS seedlist connections <https://docs.mongodb.com/manual/reference/connection-string/#dns-seedlist-connection-format/>`_, specify the connection protocol as
78+
``mongodb+srv``, followed by the DNS SRV hostname record and any
79+
options. The ``authSource`` and ``replicaSet`` options, if included in
80+
the connection string, will override any corresponding DNS-configured options
81+
set in the TXT record. Use of the ``mongodb+srv:`` connection string implicitly
82+
enables SSL (normally set with ``ssl=true``) for the client connection. The
83+
SSL option can be turned off by setting ``ssl=false`` in the query string.
84+
85+
Example:
8086
8187
.. code-block:: none
8288
83-
mongodb+srv://server.mongodb.com/?connectionTimeout=3000ms
89+
mongodb+srv://server.example.com/?connectionTimeout=3000ms
8490
8591
.. versionadded:: 3.6
8692

source/reference/connection-string.txt

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ DNS Seedlist Connection Format
141141
.. versionadded:: 3.6
142142

143143
In addition to the standard connection format, MongoDB supports a DNS-constructed
144-
seedlist. Using the DNS to construct the available servers list allows more flexibility
144+
seedlist. Using DNS to construct the available servers list allows more flexibility
145145
of deployment and the ability to change the servers in rotation without reconfiguring
146146
clients.
147147

@@ -152,57 +152,69 @@ The ``+srv`` indicates to the mongo client that the hostname that follows corres
152152
DNS SRV record. The client driver will then query the DNS for the record to determine the hosts that
153153
are running the mongod instances.
154154

155-
For example, to connect to a DNS listed hostname:
155+
For example, to connect to a DNS-listed hostname:
156156

157157
.. code-block:: none
158158

159-
mongodb+srv://server.mongodb.com/
159+
mongodb+srv://server.example.com/
160160

161161
A typical DNS configuration for the connection string above might look something
162162
like this:
163163

164164
.. code-block:: none
165165

166166
Record TTL Class Priority Weight Port Target
167-
_mongodb._tcp.server.mongodb.com. 86400 IN SRV 0 5 27317 mongodb1.mongodb.com.
168-
_mongodb._tcp.server.mongodb.com. 86400 IN SRV 0 5 27017 mongodb2.mongodb.com.
167+
_mongodb._tcp.server.example.com. 86400 IN SRV 0 5 27317 mongodb1.example.com.
168+
_mongodb._tcp.server.example.com. 86400 IN SRV 0 5 27017 mongodb2.example.com.
169169

170-
The DNS seedlist connection string can also provide options with a trailing "/?" as in
171-
the standard connection string above. However, the ``+srv`` string in the connection URI will
172-
signal to the driver to query the DNS for options as configured TXT records. For example:
170+
.. note::
171+
The hostnames returned in SRV records must share the same parent domain (in this example,``example.com``)
172+
as the given hostname.
173+
174+
The DNS seedlist connection string can also provide options as a query string, with a trailing "/?" as in
175+
the standard connection string above. However, the ``+srv`` appended to the standard connection string
176+
signals the driver to query the DNS for options as a configured TXT record.
177+
178+
Only two options are available for configuration via a TXT record --
179+
``replicaSet`` and ``authSource``, and only one TXT record
180+
is allowed per server. If multiple TXT records appear in the DNS and/or if the TXT record contains
181+
an option other than ``replicaSet`` or ``authSource``, an error will be thrown by the
182+
driver.
183+
184+
An example of a properly configured TXT record:
173185

174186
.. code-block:: none
175187

176188
Record TTL Class Text
177-
server.mongodb.com. 86400 IN TXT "ssl=true&connectTimeoutMS=250000"
178-
server.mongodb.com. 86400 IN TXT "readPreference=secondaryPreferred&readPreferenceTags=dc:ny,rack:1"
179-
189+
server.example.com. 86400 IN TXT "replicaSet=mySet&authSource=authDB"
190+
180191
In this case, taking into account both
181192
the DNS SRV records and the options retrieved from the TXT records, the parsed string will look like:
182193

183194
.. code-block:: none
184195

185-
mongodb://mongodb1.mongodb.com:27317,mongodb2.mongodb.com:27107/?ssl=true&
186-
connectTimeoutMS=250000&readPreference=secondaryPreferred&readPreferenceTags=dc:ny,rack:1
196+
mongodb://mongodb1.example.com:27317,mongodb2.example.com:27107/?replicaSet=mySet&authSource=authDB
187197

188-
The TXT records can be overridden by passing in a query string with the uri. In the example below,
189-
the only option that would be overridden in the text record would be the ``connectTimeoutMS``.
198+
Options set in a TXT record can be overridden by passing in a query string with the URI. In the example below,
199+
the query string has provided an override for the ``authSource`` option configured in the TXT record of the DNS
200+
entry above.
190201

191202
.. code-block:: none
192203

193-
mongodb+srv://server.mongodb.com/?connectTimeoutMS=300000
204+
mongodb+srv://server.example.com/?connectTimeoutMS=300000&authSource=aDifferentAuthDB
194205

195-
The rest of the option string will remain, and we can expect that the resulting uri
206+
The rest of the option string will remain, and we can expect that the resulting URI
196207
would look like this (after parse).
197208

198209
.. code-block:: none
199210

200-
mongodb://mongodb1.mongodb.com:27317,mongodb2.mongodb.com:27107/?ssl=true&connectTimeoutMS=300000&read
201-
Preference=secondaryPreferred&readPreferenceTags=dc:ny,rack:1
211+
mongodb://mongodb1.example.com:27317,mongodb2.example.com:27107/?connectTimeoutMS=300000&replicaSet=mySet&authSource=aDifferentAuthDB
202212

203213
.. note::
204-
The ``mongodb+srv`` option will fail if there is no available DNS with records which correspond to the
205-
hostname identified in the connect string.
214+
The ``mongodb+srv`` option will fail if there is no available DNS with records that correspond to the
215+
hostname identified in the connection string. In addition, use of the ``+srv`` connection string modifier
216+
sets the ``ssl`` option to ``true`` automatically for the connection. This can be overridden by explicitly setting
217+
the ``ssl`` option to ``false`` with ``ssl=false`` in the query string.
206218

207219

208220
.. index:: connections; options

0 commit comments

Comments
 (0)