reactioncommerce / reaction

Mailchimp Open Commerce is an API-first, headless commerce platform built using Node.js, React, GraphQL. Deployed via Docker and Kubernetes.
https://mailchimp.com/developer/open-commerce/
GNU General Public License v3.0
12.33k stars 2.17k forks source link

Atlas Cloud Mongo DB remote mongo db not connecting #5329

Closed adilsaeed31 closed 4 years ago

adilsaeed31 commented 5 years ago

Issue tracker is ONLY used for reporting bugs. NO NEW FEATURE REQUESTS ACCEPTED. For new features, add an issue in our Request Feature Request repository.

Are you looking for help with getting started on Reaction? Please visit our Reaction documentation.

Prerequisites

Issue Description

I am trying to connect atlas cloud mongo db with connection string it's actually connecting but giving me this error always "not authorized on admin to execute command".

Steps to Reproduce

Please provide starting context, i.e. logged in as a user, configure a particular payment method.

  1. I've just changed the mongodb url and mongodb oplog url in .env file
  2. and recreate the image and container but all in vein.
  3. just change the connection string in .env from mongodb atlas cloud and check no db will be create there.

Possible Solution

It should create the reaction database remotely to atlas cloud mongodb.

Versions

RC12 version I am running.

aldeed commented 5 years ago

@griggheo do you know whether this should work? Maybe Atlas requires you to create the db manually or you need to manually enable some extra permissions for the db user?

adilsaeed31 commented 5 years ago

Actually, accidentally I'm not sure with reaction production build I was able to create a db on mongodb atlas only for one time after that to till date my connection is actually making but mongodb is giving me the admin user is not authorized to read and write. But the user I have on mongodb is already have all the admin access and rights.

On Fri, Jul 19, 2019, 4:45 PM Eric Dobbertin notifications@github.com wrote:

@griggheo https://github.com/griggheo do you know whether this should work? Maybe Atlas requires you to create the db manually or you need to manually enable some extra permissions for the db user?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/reactioncommerce/reaction/issues/5329?email_source=notifications&email_token=ABP6I6THAIIKEO2RHKGVRIDQAHAOHA5CNFSM4IEG5XQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2LVJKQ#issuecomment-513234090, or mute the thread https://github.com/notifications/unsubscribe-auth/ABP6I6UIHZOWXITFNQQXTITQAHAOHANCNFSM4IEG5XQQ .

griggheo commented 5 years ago

@adilsaeed31 there is a difference between 1) Atlas users, who are allowed to log in to the Atlas UI and manage clusters, databases, etc that way, and 2) MongoDB users, who need to be created separately in Atlas by first creating roles with necessary permissions to one or more databases, then users associated with those roles.

In you application, you would use the 2nd type of users.

Could this be the issue you are experiencing?

adilsaeed31 commented 5 years ago

@griggheo You are correct, I have created a separated user for that but let me create one more time a new separate user for the db and I am also going to create database with name I required and with one dummy collection there, I am trying one more time and rebuilding the image and container in docker of reaction commerce, let's see it's working or not. then I'll update you here more about it. Thank you.

adilsaeed31 commented 5 years ago

@griggheo I tried but now I am getting new error MongoDB not reachable on time. previously it was connecting btw.

adilsaeed31 commented 5 years ago

@griggheo Let me tell you more, my mongodb env is sandbox

griggheo commented 5 years ago

@adilsaeed31 this falls outside of the support we can provide for our code. Make sure you whitelist your IP address in terms of Atlas MongoDB access.

adilsaeed31 commented 5 years ago

Yes my IP is whitelisted in the mongodb atlas account. If you want me to share my sandbox mongodb env with you, you can try at your own with reaction 2.0 RC 12 version, the mongodb is not connecting and working once you changed the .env file and recreate the container.

Thank you.

On Fri, Jul 19, 2019 at 8:49 PM Grig Gheorghiu notifications@github.com wrote:

@adilsaeed31 https://github.com/adilsaeed31 this falls outside of the support we can provide for our code. Make sure you whitelist your IP address in terms of Atlas MongoDB access.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/reactioncommerce/reaction/issues/5329?email_source=notifications&email_token=ABP6I6SXJU76E5RV6OBUL5TQAH5CPA5CNFSM4IEG5XQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2MJYNY#issuecomment-513317943, or mute the thread https://github.com/notifications/unsubscribe-auth/ABP6I6R2XXBEPP5JZH4GMOTQAH5CPANCNFSM4IEG5XQQ .

adilsaeed31 commented 5 years ago

@griggheo @aldeed Hi guys, Actually I got success to create a database on MongoDB cloud atlas. Unfortunately, the only solution worked for me that when I created the reaction production image and then start the container with cloud mongo atlas database url then with production image of reaction, reaction created database successfully on MongoDB cloud atlas.

This was my steps with that I am able to create the database always.

But when I tried after that the same url with development mode of reaction commerce meteor image but got the same error no success and I also tried to download the image of reactioncommerce/reaction from hub docker but still same but when I again build production image then it's working for me again.

So this is my workaround now please let me know does that make sense, and why I am unable to connect to mongo cloud atlas database in development mode of reaction commerce.

Thank you.

aldeed commented 5 years ago

There is no difference in Reaction DB connection between dev mode and production. This might be something in the Meteor layer. You could try creating a simple Meteor app from one of their templates and see if you have the same connection issue. If so, submit an issue to meteor/meteor repo.

adilsaeed31 commented 5 years ago

@aldeed By the way, before the Reaction Commerce, I never worked in Meteor, I am trying to create an eCommerce solution with reaction platform If reaction commerce is using something which has the issue then why reaction commerce isn't fixing it. Because I am Reaction Commerce user, not a Meteor if anything goes wrong. I would simply say that Reaction is not working and isn't so good not the Meteor I will say.

But I am going to launch an issue on Meteor side if it's not working there too.

aldeed commented 5 years ago

@adilsaeed31 I agree that a Meteor issue that affects Reaction is also a Reaction issue. But it's still useful for you to debug and determine for sure which layer has the issue. I do know that others are using Reaction with Atlas, so what we need is more information about what circumstances cause your issue. If it's technically a Meteor issue, it's much easier to debug and fix with a simple Meteor app, without the Reaction layer complicating things.

adilsaeed31 commented 5 years ago

@aldeed Can you give me some advice here, Atlas is better or volume storage in docker is better, keep in mind mistakenly we can destroy the volume but on Atlas data can be more secure. Thank you.

aldeed commented 5 years ago

I cannot tell you which to use, but generally it is as you say. If you are comfortable managing your own MongoDB cluster and backing up data regularly, you can and it may be cheaper. If not, managed db hosting is a good option and allows you to focus on what you are good at.

dhonig commented 5 years ago

Just wanted to weigh in here and let everyone know that I am also using MongoDB Atlas and have it connected without any issues through VPC connection peering to my AWS Reaction app on Fargate. This was really easy to set up after reading the relevant docs.

Opening up the securitygroups and mongo db atlas whitelist should also work fine.

On Wed, Jul 24, 2019 at 1:18 PM Eric Dobbertin notifications@github.com wrote:

I cannot tell you which to use, but generally it is as you say. If you are comfortable managing your own MongoDB cluster and backing up data regularly, you can and it may be cheaper. If not, managed db hosting is a good option and allows you to focus on what you are good at.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/reactioncommerce/reaction/issues/5329?email_source=notifications&email_token=AABZTL2FLPV7GCGPYVWEQGDQBCFGPA5CNFSM4IEG5XQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2XARJQ#issuecomment-514721958, or mute the thread https://github.com/notifications/unsubscribe-auth/AABZTLYVHHILH73AHN53ZSDQBCFGPANCNFSM4IEG5XQQ .

adilsaeed31 commented 5 years ago

@dhonig We are discussing here that mongodb atlas connection is not working when you are in development mode in Reaction, But when you switched to production mode it's then it's working fine. But I feel I have a free mongodb instance for now so it's kinda very slow on when you opened it first time or refresh the page after loading it will keep take same time again and again.

aldeed commented 4 years ago

It sounds like there is nothing to do here.