@@ -140,26 +140,27 @@ DNS Seedlist Connection Format
140
140
141
141
.. versionadded:: 3.6
142
142
143
- In addition to the standard connection format, MongoDB supports a DNS-constructed
144
- seedlist. Using DNS to construct the available servers list allows more flexibility
145
- of deployment and the ability to change the servers in rotation without reconfiguring
146
- clients.
143
+ In addition to the standard connection format, MongoDB supports a
144
+ DNS-constructed seedlist. Using DNS to construct the available servers
145
+ list allows more flexibility of deployment and the ability to change the
146
+ servers in rotation without reconfiguring clients.
147
147
148
- In order to leverage the DNS seedlist, use a connection string prefix of ``mongodb+srv:``
149
- in place of the ``mongodb:`` string above.
148
+ In order to leverage the DNS seedlist, use a connection string prefix of
149
+ ``mongodb+srv:`` in place of the ``mongodb:`` string above.
150
150
151
- The ``+srv`` indicates to the mongo client that the hostname that follows corresponds to a
152
- DNS SRV record. The client driver will then query the DNS for the record to determine the hosts that
153
- are running the mongod instances.
151
+ The ``+srv`` indicates to the mongo client that the hostname that
152
+ follows corresponds to a DNS SRV record. The client driver will then
153
+ query the DNS for the record to determine the hosts that are running the
154
+ mongod instances.
154
155
155
156
For example, to connect to a DNS-listed hostname:
156
157
157
158
.. code-block:: none
158
159
159
160
mongodb+srv://server.example.com/
160
161
161
- A typical DNS configuration for the connection string above might look something
162
- like this:
162
+ A typical DNS configuration for the connection string above might look
163
+ something like this:
163
164
164
165
.. code-block:: none
165
166
@@ -168,18 +169,19 @@ like this:
168
169
_mongodb._tcp.server.example.com. 86400 IN SRV 0 5 27017 mongodb2.example.com.
169
170
170
171
.. note::
171
- The hostnames returned in SRV records must share the same parent domain (in this example, ``example.com``)
172
- as the given hostname.
172
+ The hostnames returned in SRV records must share the same parent
173
+ domain (in this example, ``example.com``) as the given hostname.
173
174
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.
175
+ The DNS seedlist connection string can also provide options as a query
176
+ string, with a trailing "/?" as in the standard connection string above.
177
+ However, the ``+srv`` appended to the standard connection string signals
178
+ the driver to query the DNS for options as a configured TXT record.
177
179
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.
180
+ Only two options are available for configuration via a TXT record:
181
+ ``replicaSet`` and ``authSource``, and only one TXT record is allowed
182
+ per server. If multiple TXT records appear in the DNS and/or if the TXT
183
+ record contains an option other than ``replicaSet`` or ``authSource``,
184
+ an error will be thrown by the driver.
183
185
184
186
An example of a properly configured TXT record:
185
187
@@ -188,33 +190,36 @@ An example of a properly configured TXT record:
188
190
Record TTL Class Text
189
191
server.example.com. 86400 IN TXT "replicaSet=mySet&authSource=authDB"
190
192
191
- In this case, taking into account both
192
- the DNS SRV records and the options retrieved from the TXT records, the parsed string will look like:
193
+ In this case, taking into account both the DNS SRV records and the
194
+ options retrieved from the TXT records, the parsed string will look like:
193
195
194
196
.. code-block:: none
195
197
196
198
mongodb://mongodb1.example.com:27317,mongodb2.example.com:27017/?replicaSet=mySet&authSource=authDB
197
199
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.
200
+ Options set in a TXT record can be overridden by passing in a query
201
+ string with the URI. In the example below, the query string has provided
202
+ an override for the ``authSource`` option configured in the TXT record
203
+ of the DNS entry above.
201
204
202
205
.. code-block:: none
203
206
204
207
mongodb+srv://server.example.com/?connectTimeoutMS=300000&authSource=aDifferentAuthDB
205
208
206
- The rest of the option string will remain, and we can expect that the resulting URI
207
- would look like this (after parse).
209
+ The rest of the option string will remain, and we can expect that the
210
+ resulting URI would look like this (after parse).
208
211
209
212
.. code-block:: none
210
213
211
214
mongodb://mongodb1.example.com:27317,mongodb2.example.com:27017/?connectTimeoutMS=300000&replicaSet=mySet&authSource=aDifferentAuthDB
212
215
213
216
.. note::
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.
217
+ The ``mongodb+srv`` option will fail if there is no available DNS
218
+ with records that correspond to the hostname identified in the
219
+ connection string. In addition, use of the ``+srv`` connection string
220
+ modifier sets the ``ssl`` option to ``true`` automatically for the
221
+ connection. This can be overridden by explicitly setting the ``ssl``
222
+ option to ``false`` with ``ssl=false`` in the query string.
218
223
219
224
220
225
.. index:: connections; options
0 commit comments