@@ -93,31 +93,42 @@ Connection Troubleshooting
93
93
94
94
.. replacement:: credentials-provider-alternative-method-description
95
95
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:
99
100
100
- .. code-block:: java
101
+ .. code-block:: php
101
102
:copyable: false
102
103
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
+ ];
104
110
111
+ $client = new MongoDB\Client(
112
+ 'mongodb://<hostname>:<port>',
113
+ $uriOptions,
114
+ );
105
115
106
116
.. replacement:: authentication-guide-reference
107
117
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 `
109
119
section.
110
120
111
121
.. replacement:: verify-authentication-mechanism-anchor
112
122
113
- .. _java -verify-auth-mechanism:
123
+ .. _php -verify-auth-mechanism:
114
124
115
125
.. replacement:: authsource-param-code-block
116
126
117
- .. code-block:: java
127
+ .. code-block:: php
118
128
:copyable: false
119
129
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);
121
132
122
133
.. replacement:: dns-resolution-anchor
123
134
@@ -128,15 +139,15 @@ Connection Troubleshooting
128
139
.. code-block:: none
129
140
:copyable: false
130
141
131
- com.mongodb.MongoSocketWriteException: Exception sending message
142
+ No suitable servers found (`serverSelectionTryOnce` set): [Failed to resolve '<host>'].
132
143
133
144
.. replacement:: check-the-number-of-connections-anchor
134
145
135
- .. _java -connection-num-connections:
146
+ .. _php -connection-num-connections:
136
147
137
148
.. replacement:: mongo-client-class
138
149
139
- ``MongoClient ``
150
+ ``MongoDB\Client ``
140
151
141
152
.. replacement:: max-pool-size-param
142
153
@@ -154,13 +165,10 @@ Connection Troubleshooting
154
165
155
166
.. code-block::
156
167
157
- Command failed with error 18 (AuthenticationFailed): ' Authentication failed.' on server localhost:27017 .
168
+ Authentication failed.
158
169
159
170
.. replacement:: check-credentials-formatting-anchor
160
171
161
- .. _java-troubleshooting-connection-string-auth:
162
-
163
- .. replacement:: connection-pools-learn-more
172
+ .. _php-troubleshooting-connection-string-auth:
164
173
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