Pymongo ServerSelectionTimeoutError when using trying to find a document

It seems that whenever i try to fetch some documents i get sste error, i get a cursor object back but i cant iterate through it, tried to parse it to list but still same issue.

my code:

def update_row_cluster(cls, filter_search, load):
    collection = db[cls]
    cursor = collection.find({})
    elm = None
    for item in list(cursor):
        if item['key'] == filter_search['key']:
            elm = item
            break
    collection.update_one({'_id': elm['key']}, load, upsert=False)

exception:

Traceback (most recent call last):
  File "C:\Users\PC GAMER\Desktop\Devs\python\bots\maxim_bot\test.py", line 13, in <module>
    update_row_cluster('keys', {'key': 'MzWcKkX9CSbKD_xtjn9lyQ'}, {'$set': {'is_used': True}})
  File "C:\Users\PC GAMER\Desktop\Devs\python\bots\maxim_bot\mongo_lib.py", line 35, in update_row_cluster
    for item in list(cursor):
  File "C:\Users\PC GAMER\Desktop\Devs\python\bots\maxim_bot\lib\site-packages\pymongo\cursor.py", line 1159, in next
    if len(self.__data) or self._refresh():
  File "C:\Users\PC GAMER\Desktop\Devs\python\bots\maxim_bot\lib\site-packages\pymongo\cursor.py", line 1057, in _refresh
    self.__session = self.__collection.database.client._ensure_session()
  File "C:\Users\PC GAMER\Desktop\Devs\python\bots\maxim_bot\lib\site-packages\pymongo\mongo_client.py", line 1603, in _ensure_session
    return self.__start_session(True, causal_consistency=False)
  File "C:\Users\PC GAMER\Desktop\Devs\python\bots\maxim_bot\lib\site-packages\pymongo\mongo_client.py", line 1553, in __start_session
    server_session = self._get_server_session()
  File "C:\Users\PC GAMER\Desktop\Devs\python\bots\maxim_bot\lib\site-packages\pymongo\mongo_client.py", line 1589, in _get_server_session
    return self._topology.get_server_session()
  File "C:\Users\PC GAMER\Desktop\Devs\python\bots\maxim_bot\lib\site-packages\pymongo\topology.py", line 530, in get_server_session
    session_timeout = self._check_session_support()
  File "C:\Users\PC GAMER\Desktop\Devs\python\bots\maxim_bot\lib\site-packages\pymongo\topology.py", line 514, in _check_session_support
    self._select_servers_loop(
  File "C:\Users\PC GAMER\Desktop\Devs\python\bots\maxim_bot\lib\site-packages\pymongo\topology.py", line 216, in _select_servers_loop
    raise ServerSelectionTimeoutError(
pymongo.errors.ServerSelectionTimeoutError: reddit-shard-00-02.5yshn.mongodb.net:27017: connection closed,reddit-shard-00-01.5yshn.mongodb.net:27017: [WinError 10054] An existing connection was forcibly closed by the remote host,reddit-shard-00-00.5yshn.mongodb.net:27017: connection closed, Timeout: 30s, Topology Description: <TopologyDescription id: 61eff739510b496df0079a6b, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('reddit-shard-00-00.5yshn.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('reddit-shard-00-00.5yshn.mongodb.net:27017: connection closed')>, <ServerDescription ('reddit-shard-00-01.5yshn.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('reddit-shard-00-01.5yshn.mongodb.net:27017: [WinError 10054] An existing connection was forcibly closed by the remote host')>, <ServerDescription ('reddit-shard-00-02.5yshn.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('reddit-shard-00-02.5yshn.mongodb.net:27017: connection closed')>]>

same exception if i tried findd_one_and_update or just find_one what could be the problem. Thanks in advance.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum