|
| 1 | +.. _php-connection-troubleshooting: |
| 2 | + |
| 3 | +========================== |
| 4 | +Connection Troubleshooting |
| 5 | +========================== |
| 6 | + |
| 7 | +.. contents:: On this page |
| 8 | + :local: |
| 9 | + :backlinks: none |
| 10 | + :depth: 2 |
| 11 | + :class: singlecol |
| 12 | + |
| 13 | +.. facet:: |
| 14 | + :name: genre |
| 15 | + :values: reference |
| 16 | + |
| 17 | +.. meta:: |
| 18 | + :keywords: code example, disconnected, deployment |
| 19 | + |
| 20 | +.. sharedinclude:: dbx/connection-troubleshooting.rst |
| 21 | + |
| 22 | + .. replacement:: non-connection-issue-callout |
| 23 | + |
| 24 | + .. note:: |
| 25 | + |
| 26 | + This page addresses only connection issues. If you encounter other |
| 27 | + issues when using MongoDB or the {+library-short+}, visit the following resources: |
| 28 | + |
| 29 | + - The :ref:`Issues & Help <php-issues-and-help>` page for |
| 30 | + information about reporting bugs, contributing to the libraryß, and |
| 31 | + finding more resources |
| 32 | + - The :community-forum:`MongoDB Community Forums </tag/php>` for |
| 33 | + questions, discussions, or general technical support |
| 34 | + |
| 35 | + .. replacement:: server-selection-timeout-error |
| 36 | + |
| 37 | + .. code-block:: none |
| 38 | + :copyable: false |
| 39 | + |
| 40 | + No suitable servers found (`serverSelectionTryOnce` set): |
| 41 | + [connection refused calling hello on 'localhost:27017'] |
| 42 | + |
| 43 | + .. replacement:: check-connection-string-anchor |
| 44 | + |
| 45 | + .. _php-connection-string-port: |
| 46 | + |
| 47 | + .. replacement:: multiple-hosts-connection-guide-link |
| 48 | + |
| 49 | + To learn how to specify multiple replica set hosts, see the |
| 50 | + :ref:`Replica Sets <php-connection-replica-set>` section of the |
| 51 | + Choose a Connection Target guide. |
| 52 | + |
| 53 | + .. replacement:: configure-firewall-anchor |
| 54 | + |
| 55 | + .. _php-connection-firewall: |
| 56 | + |
| 57 | + .. replacement:: authentication-error-anchor |
| 58 | + |
| 59 | + .. _php-authentication-error: |
| 60 | + |
| 61 | + .. replacement:: scram-failure-error |
| 62 | + |
| 63 | + .. code-block:: none |
| 64 | + :copyable: false |
| 65 | + |
| 66 | + Authentication failed. |
| 67 | + |
| 68 | + .. replacement:: check-credentials-formatting-anchor |
| 69 | + |
| 70 | + .. _php-connection-string-auth: |
| 71 | + |
| 72 | + .. replacement:: learn-more-connection-string-admonition |
| 73 | + |
| 74 | + .. tip:: |
| 75 | + |
| 76 | + To learn more information about using connection strings, |
| 77 | + see :ref:`Connection URI <php-connection-uri>` in the |
| 78 | + Create a MongoDB Client guide. |
| 79 | + |
| 80 | + .. replacement:: percent-encode-example |
| 81 | + |
| 82 | + .. replacement:: verify-authentication-database-anchor |
| 83 | + |
| 84 | + .. _php-verify-auth-db: |
| 85 | + |
| 86 | + .. replacement:: authsource-param-code-block |
| 87 | + |
| 88 | + .. code-block:: java |
| 89 | + :copyable: false |
| 90 | + |
| 91 | + $uri = 'mongodb://<username>:<password>@<hostname>:<port>/?authSource=admin&authMechanism=SCRAM-SHA-256'; |
| 92 | + $client = new MongoDB\Client($uri); |
| 93 | + |
| 94 | + .. replacement:: credentials-provider-alternative-method-description |
| 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: |
| 99 | + |
| 100 | + .. code-block:: java |
| 101 | + :copyable: false |
| 102 | + |
| 103 | + MongoCredential credential = MongoCredential.createScramSha256Credential("<db_username>", "<authenticationDb>", "<dbpassword>"); |
| 104 | + |
| 105 | + |
| 106 | + .. replacement:: authentication-guide-reference |
| 107 | + |
| 108 | + To learn more about specifying authentication mechanisms, see the :ref:`java-authentication-mechanisms` |
| 109 | + section. |
| 110 | + |
| 111 | + .. replacement:: verify-authentication-mechanism-anchor |
| 112 | + |
| 113 | + .. _java-verify-auth-mechanism: |
| 114 | + |
| 115 | + .. replacement:: authsource-param-code-block |
| 116 | + |
| 117 | + .. code-block:: java |
| 118 | + :copyable: false |
| 119 | + |
| 120 | + MongoClient mongoClient = MongoClients.create("mongodb://<db_username>:<db_password>@<hostname>:<port>/?authSource=users"); |
| 121 | + |
| 122 | + .. replacement:: dns-resolution-anchor |
| 123 | + |
| 124 | + .. _java-dns-resolution-error: |
| 125 | + |
| 126 | + .. replacement:: dns-error-message |
| 127 | + |
| 128 | + .. code-block:: none |
| 129 | + :copyable: false |
| 130 | + |
| 131 | + com.mongodb.MongoSocketWriteException: Exception sending message |
| 132 | + |
| 133 | + .. replacement:: check-the-number-of-connections-anchor |
| 134 | + |
| 135 | + .. _java-connection-num-connections: |
| 136 | + |
| 137 | + .. replacement:: mongo-client-class |
| 138 | + |
| 139 | + ``MongoClient`` |
| 140 | + |
| 141 | + .. replacement:: max-pool-size-param |
| 142 | + |
| 143 | + ``maxPoolSize`` |
| 144 | + |
| 145 | + .. replacement:: max-pool-size-default |
| 146 | + |
| 147 | + ``100`` |
| 148 | + |
| 149 | + .. replacement:: max-idle-time-param |
| 150 | + |
| 151 | + ``maxIdleTimeMS`` |
| 152 | + |
| 153 | + .. replacement:: scram-failure-error |
| 154 | + |
| 155 | + .. code-block:: |
| 156 | + |
| 157 | + Command failed with error 18 (AuthenticationFailed): 'Authentication failed.' on server localhost:27017. |
| 158 | + |
| 159 | + .. replacement:: check-credentials-formatting-anchor |
| 160 | + |
| 161 | + .. _java-troubleshooting-connection-string-auth: |
| 162 | + |
| 163 | + .. replacement:: connection-pools-learn-more |
| 164 | + |
| 165 | + To learn more about how connection pooling works in the driver, see the |
| 166 | + :ref:`Connection Pools <java-connection-pools>` page. |
0 commit comments