Skip to content

How to connect using multiple nodes #855

@ghost

Description

Hi, thank you for this awesome project!

I am having trouble trying to connect to a Mongo 3.2.1 database which uses this string, provided by Compose.io:

mongodb://<user>:<password>@<host1>:<port1>,<host2>:<port2>/<db-name>?ssl=true

I tried using MONGO_URI in the configuration dictionary but it tries to connect to a local server:

/vagrant/env/local/lib/python2.7/site-packages/pymongo/topology.pyc in select_servers(self, selector, server_selection_timeout, address)
    116                 if server_timeout == 0 or now > end_time:
    117                     raise ServerSelectionTimeoutError(
--> 118                         self._error_message(selector))
    119 
    120                 self._ensure_opened()

ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused

Not sure how can I set my connection string, currently I am using just one node using these variables:

MONGO_HOST
MONGO_PORT
MONGO_DBNAME
MONGO_USERNAME
MONGO_PASSWORD

But I need to be able to use both to handle failover between nodes.

Any idea?

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