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

Starting from PyMongo v4+ can't connect to MongoDB via ssh

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      Summary

      Having MongoDB 4.2 and soon deprecation of support for this version we are moving on MongoDB version v5.+

      _Having Python project we updated driver from 3.11.1 to 4.1.1 . Running application we can get db and collections, but can't perform any data manipulations

      from pymongo import MongoClient
      
      client = MongoClient('mongodb://user:pass@localhost:27027/db_name')
      db = client.get_database('collection')
      
      print(client.server_info())
      print(db)
      collection = db.get_collection(name='collection')
      print(collection)
      print(client.list_database_names())
      print(db.list_collection_names())
      

      getting such response

      Database(MongoClient(host=['localhost:27027'], document_class=dict, tz_aware=False, connect=True), 'db_name')
      Collection(Database(MongoClient(host=['localhost:27027'], document_class=dict, tz_aware=False, connect=True), 'db_name'), 'collection')
      Traceback (most recent call last):
      _select_servers_loop
          raise ServerSelectionTimeoutError(
      pymongo.errors.ServerSelectionTimeoutError: mongo_node2: [Errno 8] nodename nor servname provided, or not known,mongo_node1:27017: [Errno 8] nodename nor servname provided, or not known, Timeout: 30s, Topology Description: <TopologyDescription id: 626bfa46ee3d10768ccaef7e, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('mongo_node1', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('mongo_node1:27017: [Errno 8] nodename nor servname provided, or not known')>, <ServerDescription ('mongo_node2', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('mongo_node2:27017: [Errno 8] nodename nor servname provided, or not known')>]>
      

      the same code but with PyMongo version lower than 4.0 is working without errors

      Motivation

      Who is the affected end user?

      BI teams

      How does this affect the end user?

      It affects local debug

      How likely is it that this problem or use case will occur?

      All the time

      If the problem does occur, what are the consequences and how severe are they?

      unavailability

      Is this issue urgent?

      Not urgent but high priority.

      Is this ticket required by a downstream team?

      might be just normal upgrade path.

      Is this ticket only for tests?

      No

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            infi32den@gmail.com Денис Евстафьев
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: