Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection issue and also connecting to wrong database with Mongo atlas (Connection time out for first request to login page). #404

Open
mishraamrish opened this issue Aug 2, 2020 · 3 comments

Comments

@mishraamrish
Copy link

mishraamrish commented Aug 2, 2020

I am using Mono Atlas for development.

MONGODB_SETTINGS = {
'db': 'xyz',
'host': 'mongodb+srv://xyz-3inen.mongodb.net',
'username': 'root',
'password': 'your_password'
}
when I don't pass database name in host i.e 'mongodb+srv://xyz-3inen.mongodb.net/xyz', it gets connected to test DB even if db and name key is present in MONGODB_SETTINGS

as I dug in, I found _sanitize_settings in connection returns "test" for DB due to URL parsing if it finds any name in URI then it assigns it or else test is the default database. so I tried passing database name in URI

The strange thing is, when the database is being connected to the test database everything works fine.

but the same is not true when I pass the database name in URI.
My first login screen gets stuck on the same screen until I refresh it, but still, the login gets successful i.e it is somehow able to get the login data for validation and validates the user in the database.

I even tried connecting using URI, the connection gets timed out for the first login request until I refresh it.

EDIT NOTE:
Now I am using connect=False but still the first request didn't get served, I Guess it's messing with flask threads something.
Hope if someone can help to get out of this

@Clickative
Copy link

Same error here!

@mishraamrish
Copy link
Author

mishraamrish commented Aug 21, 2020

It works fine with gunicorn but the same is not true with UWSGI and flask local development server, even if connect=False.

@pythonhubdev
Copy link

I am using Mono Atlas for development.

MONGODB_SETTINGS = {
'db': 'xyz',
'host': 'mongodb+srv://xyz-3inen.mongodb.net',
'username': 'root',
'password': 'your_password'
}
when I don't pass database name in host i.e 'mongodb+srv://xyz-3inen.mongodb.net/xyz', it gets connected to test DB even if db and name key is present in MONGODB_SETTINGS

as I dug in, I found _sanitize_settings in connection returns "test" for DB due to URL parsing if it finds any name in URI then it assigns it or else test is the default database. so I tried passing database name in URI

The strange thing is, when the database is being connected to the test database everything works fine.

but the same is not true when I pass the database name in URI.
My first login screen gets stuck on the same screen until I refresh it, but still, the login gets successful i.e it is somehow able to get the login data for validation and validates the user in the database.

I even tried connecting using URI, the connection gets timed out for the first login request until I refresh it.

EDIT NOTE:
Now I am using connect=False but still the first request didn't get served, I Guess it's messing with flask threads something.
Hope if someone can help to get out of this

Did you try it out with connect=True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants