Skip to content

Commit 5f7d096

Browse files
committed
edits
1 parent 9df45a1 commit 5f7d096

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

source/connect.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ Connect to MongoDB
2626
Choose a Connection Target </connect/connection-targets>
2727
Connection Options </connect/connection-options>
2828
Connect with AWS Lambda </connect/aws-lambda>
29-
30-
.. TODO:
3129
Connection Troubleshooting </connect/connection-troubleshooting>
3230

3331
Overview

source/connect/connection-options.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Set Connection Options
3434
You can configure your connection by specifying options in the connection URI or by
3535
passing them to the ``MongoDB\Client`` constructor.
3636

37-
.. _php-connection-uri:
37+
.. _php-connection-options-uri:
3838

3939
Using the Connection URI
4040
~~~~~~~~~~~~~~~~~~~~~~~~

source/connect/connection-troubleshooting.txt

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,31 +93,42 @@ Connection Troubleshooting
9393

9494
.. replacement:: credentials-provider-alternative-method-description
9595

96-
If you construct a client by using a ``MongoCredential``, the builder method
97-
corresponds to the authentication mechanism. The following code shows the builder
98-
method for the ``SCRAM-SHA-256`` authentication mechanism:
96+
If you use the ``$uriOptions`` parameter to specify an authentication mechanism,
97+
ensure that you set the ``'authMechanism'`` option to the correct mechanism. The
98+
following code shows how to specify the ``SCRAM-SHA-1`` authentication mechanism
99+
in an options parameter:
99100

100-
.. code-block:: java
101+
.. code-block:: php
101102
:copyable: false
102103

103-
MongoCredential credential = MongoCredential.createScramSha256Credential("<db_username>", "<authenticationDb>", "<dbpassword>");
104+
$uriOptions = [
105+
'username' => '<username>',
106+
'password' => '<password>',
107+
'authSource' => '<authentication database>',
108+
'authMechanism' => 'SCRAM-SHA-1',
109+
];
104110

111+
$client = new MongoDB\Client(
112+
'mongodb://<hostname>:<port>',
113+
$uriOptions,
114+
);
105115

106116
.. replacement:: authentication-guide-reference
107117

108-
To learn more about specifying authentication mechanisms, see the :ref:`java-authentication-mechanisms`
118+
To learn more about specifying authentication mechanisms, see the :ref:`php-auth`
109119
section.
110120

111121
.. replacement:: verify-authentication-mechanism-anchor
112122

113-
.. _java-verify-auth-mechanism:
123+
.. _php-verify-auth-mechanism:
114124

115125
.. replacement:: authsource-param-code-block
116126

117-
.. code-block:: java
127+
.. code-block:: php
118128
:copyable: false
119129

120-
MongoClient mongoClient = MongoClients.create("mongodb://<db_username>:<db_password>@<hostname>:<port>/?authSource=users");
130+
$uri = 'mongodb://<username>:<password>@<hostname>:<port>/?authSource=users';
131+
$client = new MongoDB\Client($uri);
121132

122133
.. replacement:: dns-resolution-anchor
123134

@@ -128,15 +139,15 @@ Connection Troubleshooting
128139
.. code-block:: none
129140
:copyable: false
130141

131-
com.mongodb.MongoSocketWriteException: Exception sending message
142+
No suitable servers found (`serverSelectionTryOnce` set): [Failed to resolve '<host>'].
132143

133144
.. replacement:: check-the-number-of-connections-anchor
134145

135-
.. _java-connection-num-connections:
146+
.. _php-connection-num-connections:
136147

137148
.. replacement:: mongo-client-class
138149

139-
``MongoClient``
150+
``MongoDB\Client``
140151

141152
.. replacement:: max-pool-size-param
142153

@@ -154,13 +165,10 @@ Connection Troubleshooting
154165

155166
.. code-block::
156167

157-
Command failed with error 18 (AuthenticationFailed): 'Authentication failed.' on server localhost:27017.
168+
Authentication failed.
158169

159170
.. replacement:: check-credentials-formatting-anchor
160171

161-
.. _java-troubleshooting-connection-string-auth:
162-
163-
.. replacement:: connection-pools-learn-more
172+
.. _php-troubleshooting-connection-string-auth:
164173

165-
To learn more about how connection pooling works in the driver, see the
166-
:ref:`Connection Pools <java-connection-pools>` page.
174+
.. replacement:: connection-pools-learn-more

0 commit comments

Comments
 (0)