Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1813

CLONE - No replica set members found yet, connecting to Atlas

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Environment:
      Ubuntu 14.04
      Mongo shell 3.6.1
      PyMongo 3.6.0
      Python 2.7.6

      Been wrestling with this for a long time. This setup works fine on a Mac. Moving the same setup to Ubuntu causes some issue relating to PyMongo connecting to our Atlas cluster. Using the mongo shell directly on the same Ubuntu box works fine. But attempting to use the MongoClient fails every time with a No replica set members found yet.

      We've tried going back to 3.4x related versions and it made no difference.

      Again, we can connect via bash using the mongo shell 3.6.1 and it works perfectly.
      However, we cannot get MongoClient (pymongo 3.4) to make the connection. We've also attempted to put in delays (concerned about forking or other conflicts), but it had no affect. We've tried connect=False (no difference).

      This fails..

      >>> from pymongo import MongoClient
      >>> atlas = "mongodb+srv://xxxx:xxxx@cluster0-xxxx.mongodb.net/test"
      >>> client = MongoClient(atlas)
      >>> db = client.test
      >>> cursor = db.transactions.count()

      Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/ubuntu/Environs/env/local/lib/python2.7/site-packages/pymongo/collection.py", line 1559, in count
      return self._count(cmd, collation, session)
      File "/home/ubuntu/Environs/env/local/lib/python2.7/site-packages/pymongo/collection.py", line 1503, in _count
      with self._socket_for_reads() as (sock_info, slave_ok):
      File "/usr/lib/python2.7/contextlib.py", line 17, in _enter_
      return self.gen.next()
      File "/home/ubuntu/Environs/env/local/lib/python2.7/site-packages/pymongo/mongo_client.py", line 979, in _socket_for_reads
      server = topology.select_server(read_preference)
      File "/home/ubuntu/Environs/env/local/lib/python2.7/site-packages/pymongo/topology.py", line 224, in select_server
      address))
      File "/home/ubuntu/Environs/env/local/lib/python2.7/site-packages/pymongo/topology.py", line 183, in select_servers
      selector, server_timeout, address)
      File "/home/ubuntu/Environs/env/local/lib/python2.7/site-packages/pymongo/topology.py", line 199, in _select_servers_loop
      self._error_message(selector))
      pymongo.errors.ServerSelectionTimeoutError: No replica set members found yet

      MongoDB shell version v3.6.1
      git version: 025d4f4fe61efd1fb6f0005be20cb45a004093d1
      OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
      allocator: tcmalloc
      modules: none
      build environment:
      distmod: ubuntu1404
      distarch: x86_64
      target_arch: x86_64

      pip freeze | grep pymongo
      pymongo==3.6.0

      python -c "import pymongo; print(pymongo.version); print(pymongo.has_c())"
      3.6.0
      True

      python --version
      Python 2.7.6

      python -c "import sys; print(sys.version)"
      2.7.6 (default, Oct 26 2016, 20:30:19)
      [GCC 4.8.4]

      $ lsb_release -a
      No LSB modules are available.
      Distributor ID: Ubuntu
      Description: Ubuntu 14.04.5 LTS
      Release: 14.04
      Codename: trusty

      But this works on the same machine…

      #!/bin/bash
      mongo "mongodb+srv://cluster0-xxxx.mongodb.net/test” --authenticationDatabase admin --username xxxx --password xxxx --ssl

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            abhishekanand25@gmail.com ABHISHEK ANAND
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: