我正在制作一个discord.py机器人,使用MongoDB作为数据库。一切正常,直到今天我收到SSL握手失败错误。 (我正在使用MongoDB Atlas来托管数据库,并且我100%确信URL正确无误)

我尝试将每个IP地址列入白名单并查看集群,但其中没有警报或其他任何东西。

client = pymongo.MongoClient("<censored>")
bot = commands.Bot(command_prefix=';')

db = client['database'] # defining database
elite = db['elite'] # defining elite collection
templates = db['templates'] # defining templates collection
collections = db.list_collection_names() # error is here


我一直期待该代码能够正常工作,因为它到目前为止一直有效,但是相反,我得到了这个错误:

Traceback (most recent call last):
  File "C:\Users\RolandPC\Desktop\client.py", line 16, in <module>
    collections = db.list_collection_names()
  File "C:\Users\RolandPC\AppData\Local\Programs\Python\Python36\lib\site-packages\pymongo\database.py", line 856, in list_collection_names
    for result in self.list_collections(session=session, **kwargs)]
  File "C:\Users\RolandPC\AppData\Local\Programs\Python\Python36\lib\site-packages\pymongo\database.py", line 819, in list_collections
    _cmd, read_pref, session)
  File "C:\Users\RolandPC\AppData\Local\Programs\Python\Python36\lib\site-packages\pymongo\mongo_client.py", line 1455, in _retryable_read
    read_pref, session, address=address)
  File "C:\Users\RolandPC\AppData\Local\Programs\Python\Python36\lib\site-packages\pymongo\mongo_client.py", line 1254, in _select_server
    server = topology.select_server(server_selector)
  File "C:\Users\RolandPC\AppData\Local\Programs\Python\Python36\lib\site-packages\pymongo\topology.py", line 231, in select_server
    address))
  File "C:\Users\RolandPC\AppData\Local\Programs\Python\Python36\lib\site-packages\pymongo\topology.py", line 189, in select_servers
    selector, server_timeout, address)
  File "C:\Users\RolandPC\AppData\Local\Programs\Python\Python36\lib\site-packages\pymongo\topology.py", line 205, in _select_servers_loop
    self._error_message(selector))
pymongo.errors.ServerSelectionTimeoutError: SSL handshake failed: cluster0-shard-00-02-vln61.mongodb.net:27017: [WinError 10054] An existing connection was forcibly closed by the remote host,SSL handshake failed: cluster0-shard-00-01-vln61.mongodb.net:27017: [WinError 10054] An existing connection was forcibly closed by the remote host,SSL handshake failed: cluster0-shard-00-00-vln61.mongodb.net:27017: [WinError 10054] An existing connection was forcibly closed by the remote host

最佳答案

没关系,只是我的互联网配置很奇怪。

关于python - MongoDB-SSL握手失败:远程主机强行关闭了现有连接,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57655083/

10-14 15:36
查看更多