Closed bujardeari closed 4 years ago
Cross-referencing with the previous two comments related to this issue:
To better help you understand the exception message, I can break down the ConnectionTimeoutException details as follows:
Collection::findOne()
in this case).serverSelectionTryOnce
set)" tell us that the driver is configured to abort after the first attempt at server selection. I'll elaborate on that later.isMaster
command on each of the three servers, which I assume are all replica set members specified in your connection string (i.e. the seed list).Unfortunately, the information in this exception doesn't reveal any additional information that would indicate a bug in the driver itself. I believe my analysis in https://github.com/mongodb/mongo-php-library/issues/546#issuecomment-482139743 is still applicable and the real culprit here may be a network connectivity issue in your deployment. As you noted in the linked comments above, you were unable to reproduce this in a local environment and a subsequent deployment in the affected production environment apparently resolves the connection problem.
serverSelectionTryOnce
PHP driver's default behavior only attempts server selection once and allows the application to fail fast rather than block for an extended amount of time and possibly allow requests to build up on the server. The behavior can be modified by the serverSelectionTryOnce
URI option. If you'd like to try disabling serverSelectionTryOnce
and allow the driver to make additional attempts to connect after a socket failure, I would strongly suggest tweaking serverSelectionTimeoutMS
below its default value of 30 seconds. Ideally, the connectionTimeoutMS
option should also be tweaked closer to (but still greater than) the expected latency between your application server and the database server. More details about the driver's internal behavior can be found in the server selection and server discovery and monitoring specifications.
for me just helped updating of php mongodb driver actually on prod all worked good, just wanted to edit website quick on local version and got same issue
How about checking your connection ips?
Description
The problem comes randomly mostly every second time i start the pod.
Environment
I have a PHP Version 7.2.14 running on kubernetes deployment on google cloud.