IDSIA / sacred

Sacred is a tool to help you configure, organize, log and reproduce experiments developed at IDSIA.
MIT License
4.2k stars 380 forks source link

Timeout to MLab #431

Closed SumNeuron closed 5 years ago

SumNeuron commented 5 years ago

I am trying to use MLab as a cloud solution for MongoObserver.

I created a free account and named my project sacred

I am now trying to add my MongoObserve but it always gives me a timeout.

From MLab:

mongodb://<USER>:<PASSWORD>@<host-shard-0>:<port>,<host-shard-1>:<port>/test? ssl=true&replicaSet=<host-shard-0>&authSource=admin&retryWrites=true

so I have this:

db_url = 'mongodb://{user}:{password}@{server_specs}/{db}{extra}'.format(
    user="me",
    password=urllib.parse.quote('myFancyP@sswrd'),
    server_specs= (
        '<shard-0>.net:<port>,'
        '<shard-1>.net:<port>,'
        '<shard-2>.net:<port>'
    ), # mlab gives me a bunch of shards...
    db="test",
    extra = '' # '?ssl=true&replicaSet=<shard-0>&authSource=admin&retryWrites=true'
)

mo = MongoObserver.create(
    url=db_url,
    ssl=True,
    # replicaSet='<shard-0>',
    # authSource='admin',
    # retryWrites=True
)

ex.observers.append(mo)

but I always get timeout...

JarnoRFB commented 5 years ago

No idea about this shards thing. Maybe you can try MongoDB Atlas instead as they acquired Mlab anyway https://cloud.mongodb.com/.

SumNeuron commented 5 years ago

@JarnoRFB I click that link and I am directed to the same place / project instance.

Then I click connect and get:

Copy the URI connection string:

mongodb://<USER>:<PASSWORD>@<host-shard-0>:<port>,<host-shard-1>:<port>/test? ssl=true&replicaSet=<host-shard-0>&authSource=admin&retryWrites=true

or

mongodb+srv://<user>:<PASSWORD>@<host>/test?retryWrites=true

Mastercorp commented 5 years ago

Have you tried: ex.observers.append(MongoObserver.create(url=mongourl, db_name='test')) You have to set the db_name in MongoObserver.create too, i guess. Works for me.

SumNeuron commented 5 years ago

@Mastercorp

I've added db_name, I still get timeout

db_name = '<DB_NAME>'
mongourl = 'mongodb://{user}:{password}@{server_specs}/{db}{extra}'.format(
    user = "<USER>",
    password = urllib.parse.quote('<PASSWORD>'),
    server_specs= (
        '<HOST-SHARD-0>:<PORT>,'
        '<HOST-SHARD-1>:<PORT>,'
        '<HOST-SHARD-2>:<PORT>'
    ),
    db=db_name,
    extra = '?ssl=true&replicaSet=<HOST-SHARD-0>&authSource=admin&retryWrites=true'
)

mo = MongoObserver.create(
    url=mongourl,
    ssl=True,
    db_name=db_name,
    # replicaSet=<HOST-SHARD-0>,
    # authSource='admin',
    # retryWrites=True
)

ex.observers.append(mo)
Mastercorp commented 5 years ago

@SumNeuron Maybe its a problem with your region? What region did you choose for your Cloud Provider? I am running on aws with Frankfurt ( eu-central-1, Free Tier ) Cluster Tier M0.

my setup looks like this: ( i named the db and HOST the same. )

mongourl = ("mongodb://USER:PASSWORD@sacred-shard-00-00-3fwam.mongodb.net:27017,"
            "sacred-shard-00-01-3fwam.mongodb.net:27017,sacred-shard-00-02-3fwam.mongodb.net:27017/sacred"
            "?ssl=true&replicaSet=sacred-shard-0&authSource=admin&retryWrites=true")
ex.observers.append(MongoObserver.create(url=mongourl,
                                         db_name='sacred'))
SumNeuron commented 5 years ago

I am running google Belgium also free

Mastercorp commented 5 years ago

@SumNeuron
must be a problem with mlab. Your code works on my setup without any problems. Mabye try to change to AWS and Frankfurt.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.