@@ -10,198 +10,143 @@ Connection Troubleshooting
1010 :depth: 2
1111 :class: singlecol
1212
13- This page offers potential solutions to issues you might encounter when
14- using the {+driver-long+} to connect to a MongoDB deployment.
13+ .. facet::
14+ :name: genre
15+ :values: reference
1516
16- .. note::
17+ .. meta::
18+ :keyworrds: code example, disconnected, deployment
1719
18- This page only addresses connection issues. If you encounter any other issues
19- with MongoDB or the driver, visit the following resources:
20+ .. sharedinclude:: dbx/connection-troubleshooting.rst
2021
21- - :ref:`rust-operation-errors` for recommendations on how to handle
22- different error types that the driver raises during operations
23- - :ref:`Issues & Help <rust-issues-and-help>` page for
24- information about reporting bugs, contributing to the driver, and
25- finding more resources
26- - `MongoDB Community Forums <https://community.mongodb.com>`__ for
27- questions, discussions, or general technical support
28-
29- ..
30- TODO:
31- - The :ref:`Frequently Asked Questions (FAQ) <rust-faq>` for the
32- {+driver-short+}
22+ .. replacement:: non-connection-issue-callout
3323
34- Server Connection Error
35- ~~~~~~~~~~~~~~~~~~~~~~~
24+ .. note::
3625
37- When you attempt to connect to a server, the {+driver-short+} might generate an
38- error message. This message might look similar to the following message indicating
39- that the driver cannot connect to a server on the specified hostname or port:
26+ This page only addresses connection issues. If you encounter any other issues
27+ with MongoDB or the driver, visit the following resources:
4028
41- .. code-block:: none
42- :copyable: false
29+ - :ref:`rust-operation-errors` for recommendations on how to handle
30+ different error types that the driver raises during operations
31+ - :ref:`Issues & Help <rust-issues-and-help>` page for
32+ information about reporting bugs, contributing to the driver, and
33+ finding more resources
34+ - `MongoDB Community Forums <https://community.mongodb.com>`__ for
35+ questions, discussions, or general technical support
36+ - The :ref:`Frequently Asked Questions (FAQ) <rust-faq>` section for
37+ common questions and corresponding answers about the
38+ {+driver-short+}
4339
44- Error: Error { kind: ServerSelection { message: "Server selection timeout:
45- No available servers. Topology: { Type: Unknown, Servers: [ { Address:
46- 127.0.0.1:27017, Type: Unknown, Error: Kind: I/O error: Connection refused
47- (os error 61), labels: {} } ] }" }, labels: {}, wire_version: None, source:
48- None }
40+ .. replacement:: server-selection-timeout-error
4941
50- The following sections describe methods that might help resolve the issue.
42+ .. code-block:: none
43+ :copyable: false
5144
52- .. _rust-troubleshooting-connection-string-port:
45+ Error: Error { kind: ServerSelection { message: "Server selection timeout:
46+ No available servers. Topology: { Type: Unknown, Servers: [ { Address:
47+ 127.0.0.1:27017, Type: Unknown, Error: Kind: I/O error: Connection refused
48+ (os error 61), labels: {} } ] }" }, labels: {}, wire_version: None, source:
49+ None }
5350
54- Check Connection String
55- -----------------------
51+ .. replacement:: check-connection-string-anchor
5652
57- Verify that the hostname and port number in the connection string are both
58- accurate. In the sample error message, the hostname is ``127.0.0.1`` and the
59- port is ``27017``. The default port value for a MongoDB instance is
60- ``27017``, but you can configure MongoDB to communicate on another port.
53+ .. _rust-troubleshooting-connection-string-port:
6154
62- .. _rust-troubleshooting -connection-firewall:
55+ .. replacement:: multiple-hosts -connection-guide-link
6356
64- Configure Firewall
65- ------------------
57+ To learn more about specifying multiple hosts in a replica set, see the
58+ :ref:`Connect to a Replica Set <rust-connect-replica-set>` section of the
59+ Connection Guide.
6660
67- Assuming that your MongoDB deployment uses the default port, verify that port
68- ``27017`` is open in your firewall. If your deployment uses a different port,
69- verify the correct port is open in your firewall.
61+ .. replacement:: configure-firewall-anchor
7062
71- .. warning: :
63+ .. _rust-troubleshooting-connection-firewall :
7264
73- Do not open a port in your firewall unless you are sure that it is the port
74- used by your MongoDB instance.
65+ .. replacement:: check-the-number-of-connections-anchor
7566
76- .. _rust-troubleshooting-connection-number-connections:
67+ .. _rust-troubleshooting-connection-number-connections:
7768
78- Check the Number of Connections
79- -------------------------------
69+ .. replacement:: mongo-client-class
8070
81- Each ``Client`` instance supports a maximum number of concurrent open
82- connections in its connection pool. The configuration parameter ``maxPoolSize``
83- defines this value and is set to ``100`` by default. If there are already a
84- number of open connections equal to ``maxPoolSize``, the server waits until
85- a connection becomes available. If this wait time exceeds the ``maxIdleTimeMS``
86- value, the driver responds with an error.
71+ ``Client``
8772
88- ..
89- TODO To learn more about how connection pools work in the driver, see
90- the :ref:`FAQ page <rust-faq-connection-pool>`.
73+ .. replacement:: max-pool-size-param
9174
92- Authentication Error
93- ~~~~~~~~~~~~~~~~~~~~
75+ ``maxPoolSize``
9476
95- The {+driver-short+} may be unable connect to a MongoDB instance if
96- the authorization is not configured correctly. In these cases, the driver
97- raises an error message similar to the following message:
77+ .. replacement:: max-pool-size-default
9878
99- .. code-block:: none
100- :copyable: false
79+ ``100``
10180
102- Error: Error { kind: Authentication { message: "SCRAM failure: bad auth :
103- authentication failed" }, labels: {}, wire_version: None, source: Some(Error
104- { kind: Command(CommandError { code: 8000, code_name: "AtlasError", message:
105- "bad auth : authentication failed", topology_version: None }),
106- labels: {}, wire_version: None, source: None }) }
81+ .. replacement:: max-idle-time-param
10782
108- The following sections describe methods that may help resolve the issue.
83+ ``maxIdleTimeMS``
10984
110- .. _rust-troubleshooting- connection-string-auth:
85+ .. replacement:: connection-pools-learn-more
11186
112- Check Connection String
113- -----------------------
87+ To learn more about how connection pools work in the driver, see
88+ :ref:`How Does Connection Pooling Work in the Rust Driver? <rust-faq-connection-pool>`
89+ on the FAQ page.
11490
115- An invalid connection string is the most common cause of authentication
116- issues when attempting to connect to MongoDB.
91+ .. replacement:: authentication-error-anchor
11792
118- .. tip: :
93+ .. _rust-troubleshooting-auth-error :
11994
120- For more information about connection strings,
121- see the :ref:`rust-quick-start-connection-string` guide.
95+ .. replacement:: scram-failure-error
12296
123- If your connection string contains a username and password, ensure that they
124- are in the correct format.
97+ .. code-block:: none
98+ :copyable: false
12599
126- .. note::
100+ Error: Error { kind: Authentication { message: "SCRAM failure: bad auth :
101+ authentication failed" }, labels: {}, wire_version: None, source: Some(Error
102+ { kind: Command(CommandError { code: 8000, code_name: "AtlasError", message:
103+ "bad auth : authentication failed", topology_version: None }),
104+ labels: {}, wire_version: None, source: None }) }
127105
128- If your username or password includes any of the following characters, you
129- must `percent encode <https://tools.ietf.org/html/rfc3986#section-2.1>`__ it:
106+ .. replacement:: check-credentials-formatting-anchor
130107
131- .. code-block:: none
132- :copyable: false
108+ .. _rust-troubleshooting-connection-string-auth:
133109
134- : / ? # [ ] @
135-
136- After percent encoding your username and password, you can use them as
137- credentials in your connection string.
110+ .. replacement:: learn-more-connection-string-admonition
138111
139- When connecting to a replica set, include all the replica set hosts in
140- your connection string. Separate each of the hosts in the connection
141- string with a comma. This enables the driver to establish a connection if
142- one of the hosts is unreachable. For an example of a connection string
143- that specifies multiple replica set hosts, see :ref:`Connect to a Replica Set
144- <rust-connect-replica-set>` in the Connection Guide.
112+ .. tip::
145113
146- .. _rust-troubleshooting-connection-auth-mechanism:
114+ For more information about connection strings,
115+ see the :ref:`rust-quick-start-connection-string` guide.
147116
148- Verify the Authentication Mechanism
149- -----------------------------------
117+ .. replacement:: verify-authentication-mechanism-anchor
150118
151- Ensure that your credentials and authentication mechanism are correct. You can
152- specify your authentication credentials in the options of your connection string
153- or in a ``Credential`` struct.
119+ .. _rust-troubleshooting-connection-auth-mechanism:
154120
155- To learn more about authentication, see the
156- :ref:`rust-authentication` guide.
121+ .. replacement:: credentials-provider-alternative-method-description
157122
158- .. _rust-troubleshooting-connection-admin:
123+ Alternatively, you can specify your authentication credentials in a
124+ ``Credential`` struct.
159125
160- Verify User Is in Authentication Database
161- -----------------------------------------
126+ .. replacement:: authentication-guide-reference
162127
163- To successfully authenticate a connection by using a username and password,
164- the username must be defined in the authentication database. The default
165- authentication database is the ``admin`` database. To use a different database
166- for authentication, specify the ``authSource`` option in the connection string.
167- The following example instructs the driver to use ``users`` as the authentication
168- database:
128+ To learn more about authentication, see the :ref:`rust-authentication` guide.
169129
170- .. code-block:: rust
171- :copyable: true
130+ .. replacement:: verify-authentication-database-anchor
172131
173- let uri = "mongodb://<username>:<password>@<hostname>:<port>/?authSource=users";
174- let client = Client::with_uri_str(uri).await?;
132+ .. _rust-troubleshooting-connection-admin:
175133
176- DNS Resolution Error
177- ~~~~~~~~~~~~~~~~~~~~
134+ .. replacement:: authsource-param-code-block
178135
179- The {+driver-short+} may be unable to resolve your DNS connection. When this
180- happens, you might receive an error message similar to the following message:
136+ .. code-block:: rust
137+ :copyable: true
181138
182- .. code-block:: none
183- :copyable: false
139+ let uri = "mongodb://<username>:<password>@<hostname>:<port>/?authSource=users";
140+ let client = Client::with_uri_str(uri).await?;
184141
185- Error: Error { kind: DnsResolve { message: "sample message. type:
186- SRV class: IN" }, labels: {}, wire_version: None, source: None }
142+ .. replacement:: dns-resolution-anchor
187143
188- If you receive this error, try the following methods to resolve the issue.
144+ .. _rust-troubleshooting-connection-dns-resolution:
189145
190- Check Database Deployment Availability
191- --------------------------------------
146+ .. replacement:: dns-error-message
192147
193- If you are using an Atlas connection string and your driver cannot find the DNS host
194- of the Atlas database deployment, the database deployment might be paused or deleted.
195- Check that the database deployment exists. If the cluster is paused, you can resume
196- the cluster on the Atlas UI or the Atlas command line interface.
148+ .. code-block:: none
149+ :copyable: false
197150
198- To learn how to resume a cluster, see :atlas:`Resume One Cluster
199- </pause-terminate-cluster/#resume-one-cluster/>` in the Atlas documentation.
200-
201- Check Connection String
202- -----------------------
203-
204- Verify that the connection string in your app is accurate. For more information
205- about verifying your connection string, see
206- :ref:`Connection Error <rust-troubleshooting-connection-string-port>`
207- and :ref:`Authentication Error <rust-troubleshooting-connection-string-auth>`.
151+ Error: Error { kind: DnsResolve { message: "sample message. type:
152+ SRV class: IN" }, labels: {}, wire_version: None, source: None }
0 commit comments