You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(connect): remove references to MongoClient.connect
We want to encourage people to manually create a new MongoClient,
and then call connect, instead of using the static method MongoClient.connect
Fixes NODE-1585
The method updates the first document where the field **a** is equal to **2** by adding a new field **b** to the document set to **1**. Next, update the callback function from **MongoClient.connect** to include the update method.
234
+
The method updates the first document where the field **a** is equal to **2** by adding a new field **b** to the document set to **1**. Next, update the callback function from **client.connect** to include the update method.
Copy file name to clipboardexpand all lines: docs/reference/content/reference/connecting/connection-settings.md
+8-5
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ title = "Connection Settings"
10
10
11
11
# URI Connection Settings
12
12
13
-
Optional connection settings are settings not covered by the [URI Connection String ](https://docs.mongodb.org/manual/reference/connection-string/). The following options are passed in the options parameter in the MongoClient.connect function.
13
+
Optional connection settings are settings not covered by the [URI Connection String ](https://docs.mongodb.org/manual/reference/connection-string/). The following options are passed in the options parameter when you create a mongo client.
The `MongoClient.connect` function returns a `Promise` that we then execute using the `await` keyword inside of an `async` function. If an error happens during the `MongoClient.connect` the error is caught by the `try`/`catch` and can be handled as if it were a normal Javascript error.
39
+
The `client.connect` function returns a `Promise` that we then execute using the `await` keyword inside of an `async` function. If an error happens during the `client.connect` the error is caught by the `try`/`catch` and can be handled as if it were a normal Javascript error.
Copy file name to clipboardexpand all lines: docs/reference/content/reference/faq/index.md
+5-4
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ title = "Frequently Asked Questions"
10
10
11
11
# What is the difference between connectTimeoutMS, socketTimeoutMS and maxTimeMS ?
12
12
13
-
| Setting | Default Value MongoClient.connect | Description |
13
+
| Setting | Default Value client.connect | Description |
14
14
| :----------| :------------- | :------------- |
15
15
| connectTimeoutMS | 30000 | The connectTimeoutMS sets the number of milliseconds a socket stays inactive before closing during the connection phase of the driver. That is to say, when the application initiates a connection, when a replica set connects to new members, or when a replica set reconnects to members. A value of 10000 milliseconds would mean the driver would wait up to 10 seconds for a response from a MongoDB server.|
16
16
| socketTimeoutMS | 360000 | The socketTimeoutMS sets the number of milliseconds a socket stays inactive after the driver has successfully connected before closing. If the value is set to 360000 milliseconds, the socket closes if there is no activity during a 6 minutes window.|
@@ -106,12 +106,13 @@ are some things to check:
106
106
allowing the driver to detect that the socket is closed.
107
107
2. The firewall should allow keepAlive probes.
108
108
109
-
# I'm getting ECONNRESET when calling MongoClient.connect
109
+
# I'm getting ECONNRESET when calling client.connect
110
110
This can occur if the connection pool is too large.
@@ -119,12 +126,11 @@ X.509 authentication requires the use of SSL connections with certificate valida
119
126
120
127
To connect using the X.509 authentication mechanism, specify `MONGODB-X509` as the mechanism in the [URI connection string](https://docs.mongodb.org/manual/reference/connection-string/), `ssl=true`, and the username. Use `enodeURIComponent` to encode the username string.
121
128
122
-
In addition to the connection string, pass to the `MongoClient.connect` method a connections options for the `server` with the X.509 certificate and other [TLS/SSL connections]({{< relref "tutorials/connect/ssl.md" >}}) options.
129
+
In addition to the connection string, pass to the new `MongoClient` a connections options for the `server` with the X.509 certificate and other [TLS/SSL connections]({{< relref "tutorials/connect/ssl.md" >}}) options.
// Connect validating the returned certificates from the server
48
+
client.connect(function(err) {
46
49
client.close();
47
50
});
48
51
```
49
52
50
53
## Disable Hostname Verification
51
54
By default, the driver ensures that the hostname included in the
52
-
server's SSL certificate(s) matches the hostname(s) provided in the URI connection string. If you need to disable the hostname verification, but otherwise validate the server's certificate, pass to the `MongoClient.connect` method:
55
+
server's SSL certificate(s) matches the hostname(s) provided in the URI connection string. If you need to disable the hostname verification, but otherwise validate the server's certificate, pass to the new `MongoClient`:
53
56
54
57
- A [URI Connection String ](https://docs.mongodb.org/manual/reference/connection-string/) that includes `ssl=true` setting,
55
58
56
59
- A connections options with the certificate for the Certificate Authority (`sslCA`) and the `sslValidate` setting set to `true` but `checkServerIdentity` set to `false`.
// Connect validating the returned certificates from the server
75
+
client.connect(function(err) {
72
76
client.close();
73
77
});
74
78
```
75
79
76
80
## Validate Server Certificate and Present Valid Certificate
77
81
If the MongoDB server performs certificate validation, the client must pass its
78
-
certificate to the server. To pass the client's certificate as well as to validate the server's certificate, pass to the `MongoClient.connect` method:
82
+
certificate to the server. To pass the client's certificate as well as to validate the server's certificate, pass to the new `MongoClient`:
79
83
80
84
- A [URI Connection String ](https://docs.mongodb.org/manual/reference/connection-string/) that includes `ssl=true` setting,
81
85
82
86
- A connections options with the `sslValidate` setting set to `true`, the certificate for the Certificate Authority (`sslCA`), the client's certificate (`sslCert`) and private key file (`sslKey`). If the client's key file is encrypted, include the password (`sslPass`).
To connect using the X.509 authentication mechanism, specify `MONGODB-X509` as the mechanism in the [URI connection string](https://docs.mongodb.org/manual/reference/connection-string/), `ssl=true`, and the username. Use `enodeURIComponent` to encode the username string.
110
115
111
-
In addition to the connection string, pass to the `MongoClient.connect` method
116
+
In addition to the connection string, pass to the new `MongoClient`
112
117
a connections options with the X.509 certificate and other [TLS/SSL connections]({{< relref "reference/connecting/connection-settings.md" >}}) options.
0 commit comments