Skip to content

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

Open

Description

@mishraamrish

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

Activity

  1. Clickative commented on Aug 21, 2020

    @Clickative

    Same error here!

  2. mishraamrish commented on Aug 21, 2020

    @mishraamrish
    Author

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

  3. pythonhubdev commented on Dec 27, 2020

    @pythonhubdev

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions