-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathconnection-options.txt
More file actions
352 lines (295 loc) · 12.3 KB
/
connection-options.txt
File metadata and controls
352 lines (295 loc) · 12.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
.. _node-connection-options:
==================
Connection Options
==================
.. facet::
:name: genre
:values: reference
.. meta::
:keywords: node.js, customize
This section explains the MongoDB connection and authentication options
supported by the driver. You can pass the connection options as
parameters of the connection URI to specify the behavior of the client.
.. list-table::
:header-rows: 1
:widths: 30 20 10 40
* - Name
- Accepted Values
- Default Value
- Description
* - **appName**
- string
- ``null``
- Specifies the app name the driver passes to the server in the client
metadata as part of the connection handshake. The driver sends the
``appName`` value to MongoDB when establishing the connection.
This value is recorded in the log file, the slow query logs, and
profile collections.
* - **authMechanism**
- string
- ``null``
- Specifies the authentication mechanism method to use for connection to the
server. If you do not specify a value, the driver uses the default mechanism,
either ``SCRAM-SHA-1`` or ``SCRAM-SHA-256`` depending on the server version. See
:ref:`authentication mechanism <node-authentication-mechanisms>` for available
authentication mechanisms.
* - **authMechanismProperties**
- comma separated key:value pairs, for example, "opt1:val1,opt2:val2"
- ``null``
- Specifies other options provided for authentication, such as the option to enable
hostname canonicalization for GSSAPI.
* - **authSource**
- string
- ``null``
- Specifies the database that connections authenticate against.
* - **autoSelectFamily**
- boolean
- ``true``
- If set to ``true``, the socket attempts to connect to IPv6 and IPv4 addresses
until a connection is established. If available, the driver will select
the first IPv6 address.
* - **autoSelectFamilyAttemptTimeout**
- non-negative integer
- ``null``
- Specifies the amount of time in milliseconds to wait for a connection
attempt to finish before trying the next address when using the
``autoSelectFamily`` option. If set to a positive integer less than ``10``,
the value ``10`` is used instead.
* - **compressors**
- comma separated list of strings, for example, "snappy,zlib,zstd"
- ``null``
- Specifies the allowed compression types for wire protocol messages
sent to or received from the server. See :ref:`node-network-compression`
for more information.
* - **connectTimeoutMS**
- non-negative integer
- ``30000``
- Specifies the amount of time, in milliseconds, to wait to establish a single TCP
socket connection to the server before raising an error. Specifying
``0`` disables the connection timeout.
* - **directConnection**
- boolean
- ``false``
- Specifies whether to force dispatch **all** operations to the host
specified in the connection URI.
* - **enableUtf8Validation**
- boolean
- ``true``
-
Specifying ``true`` enables UTF-8 validation for the
connection. MongoDB throws an error when
it attempts to serialize string data that contains invalid
UTF-8 characters to BSON. This applies to both document keys and
document values, this validation adds processing overhead.
Specifying ``false`` disables UTF-8 validation for the
connection. MongoDB does not throw errors when
data contains invalid UTF-8 data. If you disable validation,
your application avoids the validation processing overhead.
**Editing data** while validation is disabled
can result in loss of data. Disabling UTF-8 validation is a
temporary workaround to query or export data only.
You can also set UTF-8 validation in your :ref:`Node.js code
<nodejs-utf-8-validation>`. To learn more about UTF-8 characters,
see `UTF-8 <https://en.wikipedia.org/wiki/UTF-8>`__ on Wikipedia.
* - **heartbeatFrequencyMS**
- integer greater than or equal to 500
- ``null``
- Specifies the interval, in milliseconds, between regular server monitoring checks.
* - **journal**
- boolean
- ``null``
- Specifies the journal write concern for the client. See
:ref:`write concern <wc-j>` for more information.
* - **loadBalanced**
- boolean
- ``null``
- Specifies whether the driver is connecting to a load balancer.
* - **localThresholdMS**
- non-negative integer
- ``15``
- Specifies the size of the latency window, in milliseconds, on round trip time for
selecting between suitable servers. Specifying ``0`` means no wait,
meaning the fastest available server.
* - **maxIdleTimeMS**
- non-negative integer
- ``0``
- Specifies the amount of time, in milliseconds, a connection can be idle before it's closed.
Specifying ``0`` means no minimum.
* - **maxPoolSize**
- non-negative integer
- ``100``
- Specifies the maximum number of clients or connections the driver
can create in its connection pool. This count includes connections
in use.
* - **maxConnecting**
- non-negative integer
- ``2``
- Specifies the maximum number of connections a driver's connection
pool may be establishing concurrently.
* - **maxStalenessSeconds**
- -1, or an integer greater than or equal 90
- ``null``
- Specifies the maximum replication lag, in wall clock time, that
a secondary can experience and still be eligible for server selection.
Specifying ``-1`` means no maximum.
* - **minPoolSize**
- non-negative integer
- ``0``
- Specifies the number of connections the driver creates and
maintains in the connection pool even when no operations are occurring.
This count includes connections in use.
* - **proxyHost**
- string
- ``null``
- Specifies the SOCKS5 proxy IPv4 address, IPv6 address, or domain
name.
* - **proxyPort**
- non-negative integer
- ``null``
- Specifies the TCP port number of the SOCKS5 proxy server. If you
set the ``proxyHost`` option, the value of this option defaults
to ``1080``.
* - **proxyUsername**
- string
- ``null``
- Specifies the username for authentication to the SOCKS5
proxy server. If you set
this option to a zero-length string, the driver ignores it.
* - **proxyPassword**
- string
- ``null``
- Specifies the password for authentication to the SOCKS5
proxy server. If you set
this option to a zero-length string, the driver ignores it.
* - **readConcernLevel**
- string
- ``null``
- Specifies the default read concern for the client. See :ref:`read concern
<read-concern>` for more information.
* - **readPreference**
- string
- ``"primary"``
- Specifies the default read preference for the client (excluding tags). See :ref:`read preference <read-preference>` for more information.
* - **readPreferenceTags**
- comma-separated key:value pairs, for example, "dc:ny,rack:1" and "dc:ny
can be specified multiple times, each instance of this key is a
separate tag set
- ``null``
- Specifies the default read preference tags for the client. This option is
valid only if the read preference mode is not primary.
The driver uses the order of the tags in the URI as the order
for the read preference.
* - **replicaSet**
- string
- ``null``
- Specifies the name of the replica set to connect to.
* - **retryReads**
- boolean
- ``true``
- Enables retryable reads.
* - **retryWrites**
- boolean
- ``true``
- Enables retryable writes.
* - **serverMonitoringMode**
- ``auto``, ``stream``, ``poll``
- ``auto``
- Specifies the monitoring mode that the driver monitors use. When
this option is set to ``auto``, the monitoring mode is determined
by the environment in which the driver is running. The driver
uses polling mode in function-as-a-service (FaaS) environments
and the streaming mode in other environments.
* - **serverSelectionTimeoutMS**
- non-negative integer
- ``30000``
- Specifies the timeout, in milliseconds, to block for server selection
before raising an error.
* - **serverSelectionTryOnce**
- boolean
- ``true``
- Specifies to scan the topology only once after a server selection
failure instead of repeatedly until the server selection times out.
* - **socketTimeoutMS**
- non-negative integer
- ``0``
- Specifies the amount of time, in milliseconds, spent attempting to send or receive on a
socket before timing out. Specifying ``0`` means no timeout.
* - **srvMaxHosts**
- non-negative integer
- ``0``
- Specifies the maximum number of SRV results to randomly select when initially
populating the seedlist or, during SRV polling, adding new hosts to the
topology.
* - **srvServiceName**
- a valid SRV service name according to `RFC 6335 <https://datatracker.ietf.org/doc/html/rfc6335#section-5.1>`_
- ``"mongodb"``
- Specifies the service name to use for SRV lookup in initial DNS seedlist discovery.
* - **ssl**
- boolean
- ``false``
- The ``ssl`` is an alias for the ``tls`` option.
* - **tls**
- boolean
- ``false``
- Specifies whether TLS is required for connections to the server.
Using a ``srvServiceName`` of ``"mongodb+srv"``, or specifying other
``tls``-prefixed options implicitly sets the value of ``tls`` to
``true``.
* - **tlsAllowInvalidCertificates**
- boolean
- ``false``
- Specifies whether the driver generates an error when the server's
TLS certificate is invalid. Set this option to ``true`` for testing
purposes only.
* - **tlsAllowInvalidHostnames**
- boolean
- ``false``
- Specifies whether the driver generates an error when there is a mismatch
between the server's hostname and the hostname specified by the
TLS certificate. Set this option to ``true`` for testing purposes only.
* - **tlsCAFile**
- string
- ``null``
- Specifies the path to a file with either a single or bundle of certificate
authorities to trust when making a TLS connection. To learn more
about setting this connection option, see the :ref:`Provide
Certificate Filepaths <node-tls-filepaths>` section of the TLS guide.
* - **tlsCertificateKeyFile**
- string
- ``null``
- Specifies the path to the client certificate file or the client
private key file. If you need both, you must concatenate the
files. To learn more about setting this connection option, see
the :ref:`Provide Certificate Filepaths <node-tls-filepaths>`
section of the TLS guide.
* - **tlsCertificateKeyFilePassword**
- string
- ``null``
- Specifies the password to decrypt the client private key to be used
for TLS connections.
* - **tlsInsecure**
- boolean
- ``false``
- Specifies to relax TLS constraints as much as possible, such as
allowing invalid certificates or hostname mismatches. Set this option
to ``true`` for testing purposes only.
* - **w**
- non-negative integer or string
- ``null``
- Specifies the default write concern ``"w"`` field for the client.
* - **waitQueueTimeoutMS**
- non-negative integer
- ``0``
- Specifies the amount of time, in milliseconds, spent attempting to check out a connection
from a server's connection pool before timing out.
* - **wTimeoutMS**
- non-negative integer
- ``null``
- Specifies the default write concern timeout field for the client.
* - **zlibCompressionLevel**
- integer between ``-1`` and ``9`` (inclusive)
- ``-1``
- Specifies the level of compression when using zlib to compress wire
protocol messages. ``-1`` signifies the default level, ``0`` signifies
no compression, ``1`` signifies the fastest speed, and ``9`` signifies
the best compression. See :ref:`node-network-compression` for more information.