Format for MONGO_URL when connecting MongoDB Atlas to Galaxy - mongodb

Revising this question following more attempts:
I'm deploying a Meteor app on Galaxy for the first time and cannot connect to MongoDB Atlas.
I can connect to MongoDb through Mongo Shell using:
mongo "mongodb://host1:27017,host2:27017,host3:27017/<db_name>?replicaSet=<replica_set_name>" --ssl --authenticationDatabase admin --username <username> --password <password>
I tried an equivalent for the Mongo URL in my settings.json:
mongodb://<username>:<password>#host1:27017,host2:27017,host3:27017/<db_name>?authSource=admin&replicaSet=<replace_set_name>
But when I deploy my app, I get:
Error: Could not locate any valid servers in initial seed list.
I've also tried using the connection string provided by Atlas:
mongodb+srv://<username>:<password>#<host>/<db_name>?retryWrites=true&w=majority
But this just returns:
Error: URL must be in the format mongodb://user:pass#host:port/dbname
I've tried every combination I can come up with but no luck.
RESOLVED, WITH HELP FROM MONGODB ATLAS SUPPORT:
"MONGO_URL": "mongodb://:#host1:27017,host2:27017,host3:27017/?ssl=true&replicaSet=&authSource=admin&retryWrites=true&w=majority",

Related

Unable to connect to MongoDB Atlas Cluster from Mongosh terminal

I am trying to connect to the Mongo Atlas Cluster through the Mongosh terminal using mongosh "mongodb+srv://cluster0.sdwcf.mongodb.net/myFirstDatabase" --username <username>. But I am unable to connect the error being Error: queryTxt ETIMEOUT cluster0.sdwcf.mongodb.net. I found the same issue at https://github.com/metabase/metabase/issues/9867 but issue has been closed without any solution.
One the other hand if I try to connect using the mongo 3.4 or earlier command mongo "mongodb://cluster0-shard-00-00.sdwcf.mongodb.net:27017,cluster0-shard-00-01.sdwcf.mongodb.net:27017,cluster0-shard-00-02.sdwcf.mongodb.net:27017/myFirstDatabase?replicaSet=atlas-10n7hz-shard-0" --ssl --authenticationDatabase admin --username <username> --password <password> it works just fine. But given that the Mongosh terminal has superseded the Mongo terminal, I would really like to know if there is any fix for this..

error in connection mongodb atlas to shell

mongo "mongodb+srv://sandbox-hoj54.mongodb.net/test" --authenticationDatabase admin --username m001-student --password m001-mongodb-basics
2020-06-19T14:18:02.553+0530 E QUERY [js] uncaught exception: SyntaxError: unexpected token: string literal :
#(shell):1:6
I think the problem is that you are running this command:
mongo "mongodb+srv://cluster0-jxrfu.mongodb.net/<dbname>" --username <password> on the MongoDB shell you downloaded in your <your mongo shell's download directory>/bin directory.
Instead, Open up a new command line and run the command. It worked for me.
There are two options to connect to db. Connect with the mongo shell or connect your application. It seems that you are trying to connect by the shell. You can see your connection string in the window:
MongoDB Atlas Panel > Clusters > 'Connect' button.
Of course you have to replace <dbname> and <password> as in the description.

Why can't `mongoimport` connect to my free-tier MongoDB Atlas cluster?

I have a free-tier MongoDB Atlas cluster, and I want to upload some JSON to it from my Mac.
I tried to run this:
mongoimport -h cluster0-shard-00-00-cxacx.mongodb.net:27017 -d literature -c books -u xxxx -p xxxx --file ~/Desktop/books.json --type json --ssl
However, I got this error:
Failed: error connecting to db server: no reachable servers, openssl error: SSL errors: SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
I tried without --ssl in the command, and I got this instead:
Failed: error connecting to db server: no reachable servers
Why can't it reach the server?
More info:
My mongoimport version is r3.2.22.
My OS is macOS 10.14.5.
My cluster version is 4.0.10.
The user has admin permission.
My IP address is white-listed.
I can connect to the cluster with the MongoDB Node Driver.
I get the same problem with mongofiles.
I also tried variations of the command with no success that included --authenticationDatabase admin and the name of the replica set and other server nodes.
Update: I was able to upload the JSON file by sending it to a Linux cloud server and running mongoimport from there.
Monogo atlas gives you service records (SRV) and not host.
"cluster0-shard-00-00-cxacx.mongodb.net" It is not a proper host.
Use it like:
mongoimport --uri
"mongodb://root:#atlas-host1:27017,atlas-host2:27017,atlas-host3:27017/?ssl=true&replicaSet=myAtlasRS&authSource=admin"
-d literature -c books -file ~/Desktop/books.json --type json --ssl
You will get complete URI from mongo atlas connect screen

Why cant I connect to replica set using mongo shell?

I can connect to replica set using following command from mongo shell version 3.2.11. But the same does not works with mongo shell v3.4.1.
mongo --host \
"replicaSet1/10.10.10.15:27001,10.10.10.16:27002,10.10.10.17:27000" mydbname \
-u root -p root \
--authenticationDatabase admin
[main] Error: Failed to parse mongodb:// URL: mongodb://replicaSet1/10.10.10.15:27001,10.10.10.16:27002,10.10.10.17:27000/mydbname :
I have read here that replica set address format has not changed since v 3.4.1 release.
Why cant I connect to db ? What is the parse error, as per new format(if its there).
This is a known regression in MongoDB 3.4.0/3.4.1: SERVER-27289: mongo --host replSet/Host:Port no longer works. A fix has been committed for the upcoming MongoDB 3.4.2 release.
You can work around this in an affected 3.4.x mongo shell by using the standard MongoDB Connection String URI format instead:
mongo --host mongodb://10.10.10.15:27001,10.10.10.16:27002,10.10.10.17:27000/mydbname?replicaSet=replicaSet1
You can also use a standard MongoDB Connection String as a plain argument (i.e. without the --host parameter):
mongo mongodb://10.10.10.15:27001,10.10.10.16:27002,10.10.10.17:27000/mydbname?replicaSet=replicaSet1
I have read here that replica set address format has not changed since v 3.4.1 release.
Support for using the standard MongoDB Connecting String format in the --host parameter was added in MongoDB 3.4 in order to align the mongo shell connection string syntax with the format used by all official drivers.
This change is currently not noted in the MongoDB 3.4 manual, so I've raised DOCS-9808 to clarify.

Connecting to mongolab db in the shell, but not in Robomongo

I am trying to connect to a MongoLab DB using the credentials and user I set up. I chose the AWS instance using the 500mb of storage (the free Sandbox version). It said it was 3.0.x for Mongo (showing 3.0.9 in MongoLab).
On my environment I am running MongoDB shell version: 3.2.1
Using the command:
mongo ds011111.mongolab.com:11111/mydbname -u dbname -p dbpass
in the shell, I am able to connect to the DB just fine. However, when trying to connect through Robomongo, I am not. I am using the same username, password, database name, host and port. When I run the test, it connects to the host and port just fine, but it says Authorization Fails (this should not be, as I was just authorized to connect in the shell).
What is going?
There is nothing wrong. Just RoboMongo 0.8.x does not support Mongo 3.0+. You can download 0.9 RC4.