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

Async client no longer works on Atlas mongodb Cloud

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • 4.12.1
    • Affects Version/s: 4.11.3
    • Component/s: API, Atlas Testing
    • None
    • Python Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      Detailed steps to reproduce the problem?

      Async driver worked a few days ago with same version. Please check this repository and this PR for confirmation. But now I am getting the following error (also see here  for the test failure in Github actions) 

      Note that the same version works for regular `MongoClient`

      Steps to reproduce

      python3 -m asyncio
      asyncio REPL 3.13.2 (main, Mar 29 2025, 10:04:43) [GCC 14.2.0] on linux
      Use "await" directly instead of "asyncio.run()".
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import asyncio
      >>> import pymongo
      >>> client = pymongo.AsyncMongoClient("mongodb+srv://<user>:<password>@<host>/retryWrites=true&w=majority")
      >>> await client.list_database_names()
      Traceback (most recent call last):
        File "/usr/lib/python3.13/concurrent/futures/_base.py", line 456, in result
          return self.__get_result()
                 ~~~~~~~~~~~~~~~~~^^
        File "/usr/lib/python3.13/concurrent/futures/_base.py", line 401, in __get_result
          raise self._exception
        File "<python-input-2>", line 1, in <module>
          await client.list_database_names()
        File "/home/masterkenway/Projects/xin/.venv/lib/python3.13/site-packages/pymongo/asynchronous/mongo_client.py", line 2348, in list_database_names
          res = await self._list_databases(session, nameOnly=True, comment=comment)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/masterkenway/Projects/xin/.venv/lib/python3.13/site-packages/pymongo/asynchronous/mongo_client.py", line 2295, in _list_databases
          res = await admin._retryable_read_command(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              cmd, session=session, operation=_Op.LIST_DATABASES
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          )
          ^
        File "/home/masterkenway/Projects/xin/.venv/lib/python3.13/site-packages/pymongo/asynchronous/database.py", line 1071, in _retryable_read_command
          return await self._client._retryable_read(_cmd, read_preference, session, operation)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/masterkenway/Projects/xin/.venv/lib/python3.13/site-packages/pymongo/asynchronous/mongo_client.py", line 2011, in _retryable_read
          return await self._retry_internal(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
          ...<9 lines>...
          )
          ^
        File "/home/masterkenway/Projects/xin/.venv/lib/python3.13/site-packages/pymongo/_csot.py", line 109, in csot_wrapper
          return await func(self, *args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/masterkenway/Projects/xin/.venv/lib/python3.13/site-packages/pymongo/asynchronous/mongo_client.py", line 1967, in _retry_internal
          return await _ClientConnectionRetryable(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          ...<10 lines>...
          ).run()
          ^^^^^^^
        File "/home/masterkenway/Projects/xin/.venv/lib/python3.13/site-packages/pymongo/asynchronous/mongo_client.py", line 2723, in run
          return await self._read() if self._is_read else await self._write()
                 ^^^^^^^^^^^^^^^^^^
        File "/home/masterkenway/Projects/xin/.venv/lib/python3.13/site-packages/pymongo/asynchronous/mongo_client.py", line 2868, in _read
          self._server = await self._get_server()
                         ^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/masterkenway/Projects/xin/.venv/lib/python3.13/site-packages/pymongo/asynchronous/mongo_client.py", line 2816, in _get_server
          return await self._client._select_server(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          ...<6 lines>...
          )
          ^
        File "/home/masterkenway/Projects/xin/.venv/lib/python3.13/site-packages/pymongo/asynchronous/mongo_client.py", line 1797, in _select_server
          server = await topology.select_server(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          ...<4 lines>...
          )
          ^
        File "/home/masterkenway/Projects/xin/.venv/lib/python3.13/site-packages/pymongo/asynchronous/topology.py", line 409, in select_server
          server = await self._select_server(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
          ...<6 lines>...
          )
          ^
        File "/home/masterkenway/Projects/xin/.venv/lib/python3.13/site-packages/pymongo/asynchronous/topology.py", line 387, in _select_server
          servers = await self.select_servers(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
              selector, operation, server_selection_timeout, address, operation_id
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          )
          ^
        File "/home/masterkenway/Projects/xin/.venv/lib/python3.13/site-packages/pymongo/asynchronous/topology.py", line 294, in select_servers
          server_descriptions = await self._select_servers_loop(
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              selector, server_timeout, operation, operation_id, address
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          )
          ^
        File "/home/masterkenway/Projects/xin/.venv/lib/python3.13/site-packages/pymongo/asynchronous/topology.py", line 344, in _select_servers_loop
          raise ServerSelectionTimeoutError(
              f"{self._error_message(selector)}, Timeout: {timeout}s, Topology Description: {self.description!r}"
          )
      pymongo.errors.ServerSelectionTimeoutError: 'SSLContext' object has no attribute 'wrap_bio','SSLContext' object has no attribute 'wrap_bio','SSLContext' object has no attribute 'wrap_bio', Timeout: 30s, Topology Description: <TopologyDescription id: 67f89cd47ec600037487addb, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription (<shard0>, 27017) server_type: Unknown, rtt: None, error=AttributeError("'SSLContext' object has no attribute 'wrap_bio'")>, <ServerDescription (<shard1>, 27017) server_type: Unknown, rtt: None, error=AttributeError("'SSLContext' object has no attribute 'wrap_bio'")>, <ServerDescription (<shard2>, 27017) server_type: Unknown, rtt: None, error=AttributeError("'SSLContext' object has no attribute 'wrap_bio'")>]>
      >>>  

      Definition of done: what must be done to consider the task complete?

      The exact Python version used, with patch level:

      $ python -c "import sys; print(sys.version)"

      The exact version of PyMongo used, with patch level:

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

      Describe how MongoDB is set up. Local vs Hosted, version, topology, load balanced, etc.

      Atlas mongodb from cloud.

      The operating system and version (e.g. Windows 7, OSX 10.8, ...)

      Debian 13 Trixie

      Web framework or asynchronous network library used, if any, with version (e.g. Django 1.7, mod_wsgi 4.3.0, gevent 1.0.1, Tornado 4.0.2, ...)

       

      "aiomysql>=0.2.0",    "asyncpg>=0.29.0",    "mypy>=1.11.2",    "pymssql>=2.3.1",    "sqlalchemy>=2.0.35",    "pydantic>=2.9.2",    "polars>=1.8.2",    "pandas>=2.2.3",    "cryptography>=43.0.1",    "pandas-stubs>=2.2.2.240909",    "pyarrow>=17.0.0",    "pymongo[encryption,ocsp,snappy]>=4.11.3" 

       

       

      Security Vulnerabilities

      If you’ve identified a security vulnerability in a driver or any other MongoDB project, please report it according to the instructions here

            Assignee:
            iris.ho@mongodb.com Iris Ho
            Reporter:
            billalmasum93@gmail.com Masum Billal
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: