使用Python的ElasticSearch ping()返回FALSE

vzgqcmou  于 2022-10-06  发布在  Python
关注(0)|答案(1)|浏览(273)

正在尝试从Python ping到ElasticSearch https://localhost:9200es.ping()返回FALSE。

从浏览器我可以用用户名和密码连接到https://localhost:9200(只有第一次被要求)。

def connect_elasticsearch():
    es = None
    es = Elasticsearch(['https://localhost:9200'], basic_auth=('elastic', 'password'))
    print(es)
    if es.ping():
        print('Yupiee  Connected ')
    else:
        print('Awww it could not connect!')
    return es

es1 = connect_elasticsearch()

产出:

<Elasticsearch(['https://localhost:9200'])>
Awww it could not connect!
ffscu2ro

ffscu2ro1#

TLDR;

根据文档,
此API调用可能在传输层失败(由于连接错误或超时),也可能因非2XX HTTP响应失败(由于身份验证或授权问题)。

解决方案

为了能够继续,请使用下面的行

print(es.info())

这应该会帮助您了解哪里出了问题。

我怀疑证书不可信。

相关问题