A
A
Araik2019-10-12 16:54:02
PHP
Araik, 2019-10-12 16:54:02

Why do I get an Invalid URI Schema, expecting 'mongodb://' error in production?

On local (Win10 + PHP7) everything is ok.
I transfer CMS to the server and I get an error:

Ошибка системы: Failed to parse MongoDB URI: 'mongodb+srv://логин:пароль@cluster-a-a8wbv.gcp.mongodb.net/test?retryWrites=true&w=majority'. Invalid URI Schema, expecting 'mongodb://'.
/var/www/html/vendor/mongodb/mongodb/src/Client.php в строке 87

Ubuntu Server 18.04, NGINX+PHP-FPM
If I specify:
mongodb://логин:пароль@cluster-a-a8wbv.gcp.mongodb.net/test?retryWrites=true&w=majority

those. I remove from shema +srv , I get an error:
Ошибка системы: No suitable servers found (`serverSelectionTryOnce` set): [Failed to resolve 'cluster-a-a8wbv.gcp.mongodb.net']
/var/www/html/vendor/mongodb/mongodb/src/Collection.php в строке 612

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
grinat, 2019-10-12
@NinjaNickName

Docker because you need to use it and then there will be no such garbage. And in the case, then you have an old version of the lib for working with mongo on the server. If memory serves, then in order to work like srv without +srv, you need to specify some option through ?, just like you specify ?retryWrites=true

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question