MongoDB: периодические ошибки подключения на PHP ⇐ Php
-
Anonymous
MongoDB: периодические ошибки подключения на PHP
I have been using MongoDB for several years with PHP. Using ScaleGrid server (replicaset) MongoDB is not installed on my server. I use MongoDB driver 1.17.2 (https://github.com/mongodb/mongo-php-driver). Most of the time everything goes well but very randomly in the logs I find the following error:
2024/03/06 04:50:02 [error] 13667#13667: *2092875 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught MongoDB\Driver\Exception\ConnectionTimeoutException: No suitable servers found (`serverSelectionTryOnce` set): [Failed to resolve 'sg-hebergemeweb2-48289.servers.mongodirector.com'] [Failed to resolve 'sg-hebergemeweb2-48291.servers.mongodirector.com'] in /var/www/PROD/rewrite/versions/v0.61/vendor/mongodb/mongodb/src/functions.php:520 Stack trace: #0 /var/www/PROD/rewrite/versions/v0.61/vendor/mongodb/mongodb/src/functions.php(520): MongoDB\Driver\Manager->selectServer() #1 /var/www/PROD/rewrite/versions/v0.61/vendor/mongodb/mongodb/src/Collection.php(1108): MongoDB\select_server() #2 /var/www/PROD/rewrite/versions/v0.61/class/Bdd.class.php(185): MongoDB\Collection->updateOne() #3 /var/www/PROD/rewrite/versions/v0.61/conf/session_config.php(52): Bdd->__call() #4 [internal function]: Session->write() #5 [internal function]: session_write_close() #6 {main} thrown in /var/www/PROD/rewrite/versions/v0.61/v" while reading response header from upstream, client: 172.70.247.215, server: example.com, request: "GET /ajax/process HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "example.com" I contacted the ScaleGrid support team and they told me:
"From our side, your cluster works without any problems all year round: the information I got from online forums shows that this could be a problem in the connection string and you may need to replace localhost with 127.0.0.1. Please refer to additional information below: MongoDB no suitable servers found MongoDB connection error: MongoTimeoutError: Server selection timed out after 30000 ms mongodb-connection-error-mongotimeouterror-server-selection-timed-out-after-30 Hope this helps."
Replace localhost with 127.0.0.1? Since I don't have the MongoDB server installed, I don't see how to make this modification? I don't use 127.0.0.1 or localhost in my connection string.
I see that other users are having the same problem: https://www.mongodb.com/community/forum ... -php/14530
The problem seems difficult to resolve because it occurs randomly and infrequently (approximately once every 3 days) the rest of the time everything goes well...
Do you have any leads?
Thank you in advance for your precious help
Источник: https://stackoverflow.com/questions/781 ... ors-on-php
I have been using MongoDB for several years with PHP. Using ScaleGrid server (replicaset) MongoDB is not installed on my server. I use MongoDB driver 1.17.2 (https://github.com/mongodb/mongo-php-driver). Most of the time everything goes well but very randomly in the logs I find the following error:
2024/03/06 04:50:02 [error] 13667#13667: *2092875 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught MongoDB\Driver\Exception\ConnectionTimeoutException: No suitable servers found (`serverSelectionTryOnce` set): [Failed to resolve 'sg-hebergemeweb2-48289.servers.mongodirector.com'] [Failed to resolve 'sg-hebergemeweb2-48291.servers.mongodirector.com'] in /var/www/PROD/rewrite/versions/v0.61/vendor/mongodb/mongodb/src/functions.php:520 Stack trace: #0 /var/www/PROD/rewrite/versions/v0.61/vendor/mongodb/mongodb/src/functions.php(520): MongoDB\Driver\Manager->selectServer() #1 /var/www/PROD/rewrite/versions/v0.61/vendor/mongodb/mongodb/src/Collection.php(1108): MongoDB\select_server() #2 /var/www/PROD/rewrite/versions/v0.61/class/Bdd.class.php(185): MongoDB\Collection->updateOne() #3 /var/www/PROD/rewrite/versions/v0.61/conf/session_config.php(52): Bdd->__call() #4 [internal function]: Session->write() #5 [internal function]: session_write_close() #6 {main} thrown in /var/www/PROD/rewrite/versions/v0.61/v" while reading response header from upstream, client: 172.70.247.215, server: example.com, request: "GET /ajax/process HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "example.com" I contacted the ScaleGrid support team and they told me:
"From our side, your cluster works without any problems all year round: the information I got from online forums shows that this could be a problem in the connection string and you may need to replace localhost with 127.0.0.1. Please refer to additional information below: MongoDB no suitable servers found MongoDB connection error: MongoTimeoutError: Server selection timed out after 30000 ms mongodb-connection-error-mongotimeouterror-server-selection-timed-out-after-30 Hope this helps."
Replace localhost with 127.0.0.1? Since I don't have the MongoDB server installed, I don't see how to make this modification? I don't use 127.0.0.1 or localhost in my connection string.
I see that other users are having the same problem: https://www.mongodb.com/community/forum ... -php/14530
The problem seems difficult to resolve because it occurs randomly and infrequently (approximately once every 3 days) the rest of the time everything goes well...
Do you have any leads?
Thank you in advance for your precious help
Источник: https://stackoverflow.com/questions/781 ... ors-on-php
Мобильная версия