首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ServerSelectionTimeoutError( pymongo.errors.ServerSelectionTimeoutError: 147.234.32.246:27017

ServerSelectionTimeoutError( pymongo.errors.ServerSelectionTimeoutError: 147.234.32.246:27017
EN

Stack Overflow用户
提问于 2021-01-05 10:52:40
回答 1查看 69关注 0票数 0

我尝试从pycharm(使用RDP)远程连接到mongodb服务器。这是我运行的函数:

代码语言:javascript
复制
cluster = MongoClient("mongodb://admin:Passw0rd!@147.234.32.246:27017/NEG")
db = cluster["NEG"]

for word in Setting.dictionary_global.keys():
    if word in db.list_collection_names():
        collection = db[word]
        for file in Setting.dictionary_global[word].keys():
            if collection.find({"url":Setting.dictionary_global[word][file].url}):
                continue
            num_of_appearance = len(Setting.dictionary_global[word][file].indexes.get(word))
            post = {"url": file, "title": Setting.dictionary_global[word][file].title,
                    "description": Setting.dictionary_global[word][file].description,"word in page": Setting.dictionary_global[word][file].indexes,"appearance": num_of_appearance, "date modified": Setting.dictionary_global[word][file].time}
            collection.insert_one(post)

    else:
        collection = db.create_collection(word)
        for file in Setting.dictionary_global[word].keys():

            #print(Setting.dictionary_global)
            num_of_appearance = len(Setting.dictionary_global[word][file].indexes.get(word))
            post = {"url": file, "title": Setting.dictionary_global[word][file].title,
                    "description": Setting.dictionary_global[word][file].description,"word in page": Setting.dictionary_global[word][file].indexes, "appearance": num_of_appearance, "date modified":Setting.dictionary_global[word][file].time}
            collection.insert_one(post)

我得到了这个错误:

“”“

回溯(最近一次调用):文件"C:/Users/edend/PycharmProjects/pythonProject11/main.py",行118,在crawler.start()文件"C:\Users\edend\PycharmProjects\pythonProject11\DB.py",行110中,在start insertDB()文件"C:\Users\edend\PycharmProjects\pythonProject11\venv\lib\site-packages\pymongo\database.py",行10中,如果word在db.list_collection_names()中,则在insertDB中:文件db.list_collection_names行863,in list_collection_names for result in self.list_collections(session=session,**kwargs)]文件返回行825,在list_collections return self.__client._retryable_read(文件返回行1460,在文件服务器= self._select_server(文件"C:\Users\edend\PycharmProjects\pythonProject11\venv\lib\site-packages\pymongo\mongo_client.py",行1278,在_select_server服务器= topology.select_server(server_selector)文件服务器行241中,在select_server return random.choice(self.select_servers(选择器,File "C:\Users\edend\PycharmProjects\pythonProject11\venv\lib\site-packages\pymongo\topology.py",行199,in select_servers server_descriptions = self._select_servers_loop(文件提升行215,in _select_servers_loop raise ServerSelectionTimeoutError( pymongo.errors.ServerSelectionTimeoutError: 147.234.32.246:27017:超时,超时: 30s,拓扑描述:>

“”“

请帮我把我卡住,我什么都试一试,谢谢!!

EN

回答 1

Stack Overflow用户

发布于 2021-01-06 01:23:12

常见原因:

running

  • MongoDB MongoDB服务器不是
  • MongoDB服务器运行在不同的端口上
  • 客户端和服务器之间没有连接(您是否可以将ping)
  • mongod.conf配置为默认情况下仅允许本地连接(设置bind_ip_all?)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65572587

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档