- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试从 python 脚本查询 elasticsearch,但出现异常。
我遵循了官方指南,例如 this one .但是当我试图查询 elasticsearch 时,没有成功。这里是异常(exception):
File "C:\...\connection\http_urllib3.py", line 250, in perform_request
raise ConnectionError("N/A", str(e), e)
elasticsearch.exceptions.ConnectionError:
ConnectionError(check_hostname requires server_hostname) caused by: ValueError(check_hostname requires server_hostname)
这是我的代码:
from elasticsearch import Elasticsearch
from elasticsearch import RequestsHttpConnection
from ssl import create_default_context
import ssl
context = create_default_context(cafile="certificate.pem")
es = Elasticsearch("https://localhost", ssl_context=context, http_auth=('username','password'))
res = es.search(index="dr_*", body = {
'size' : 10,
'query': {
'match_all' : {}
}
})
为什么会这样?
最佳答案
不幸的是,我也遇到了这样的问题。
默认情况下,context中check_hostname的值为True,所以你必须指定server_hostname。这是一个简单的解决方案,只需在创建上下文后添加以下行
context.check_hostname = False
它应该没有任何问题
关于python - 为什么弹性会引发此异常 "elasticsearch.exceptions.ConnectionError: ConnectionError(check_hostname requires server_hostname)"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59068397/
p={ 'http':'http://my correct proxy here', 'https':'https://my correct proxy here' } sel
使用最新的请求库和 Python 3.8.5,我似乎无法“禁用”对 API 调用的证书检查。我了解不禁用的原因,但我希望它起作用。 当我尝试使用“verify=True”时,我连接的服务器抛出此错误:
我正在尝试从 python 脚本查询 elasticsearch,但出现异常。 我遵循了官方指南,例如 this one .但是当我试图查询 elasticsearch 时,没有成功。这里是异常(ex
我在使用gae时出现如下错误: TypeError: __init__() got an unexpected keyword argument 'check_hostname' 堆栈跟踪: File
我是一名优秀的程序员,十分优秀!