试图将elasticsearch停靠器容器与elasticsearch客户端连接时出现此错误。
/home/raihan/dev/aims_lab/ai_receptionist/env/lib/python3.6/site-packages/elasticsearch/_sync/client/__init__.py:379: SecurityWarning: Connecting to 'https://localhost:9200' using TLS with verify_certs=False is insecure
**transport_kwargs,
<Elasticsearch(['https://localhost:9200'])>
Traceback (most recent call last):
File "test_all.py", line 29, in <module>
resp = es.index(index="test-index", id=1, document=doc)
File "/home/raihan/dev/aims_lab/ai_receptionist/env/lib/python3.6/site-packages/elasticsearch/_sync/client/utils.py", line 404, in wrapped
return api(*args, **kwargs)
File "/home/raihan/dev/aims_lab/ai_receptionist/env/lib/python3.6/site-packages/elasticsearch/_sync/client/__init__.py", line 2218, in index
__method, __path, params=__query, headers=__headers, body=__body
File "/home/raihan/dev/aims_lab/ai_receptionist/env/lib/python3.6/site-packages/elasticsearch/_sync/client/_base.py", line 295, in perform_request
client_meta=self._client_meta,
File "/home/raihan/dev/aims_lab/ai_receptionist/env/lib/python3.6/site-packages/elastic_transport/_transport.py", line 334, in perform_request
request_timeout=request_timeout,
File "/home/raihan/dev/aims_lab/ai_receptionist/env/lib/python3.6/site-packages/elastic_transport/_node/_http_urllib3.py", line 199, in perform_request
raise err from None
elastic_transport.TlsError: TLS error caused by: TlsError(TLS error caused by: SSLError([SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:852)))elastic.py的内容
host = "https://localhost:9200"
es = Elasticsearch(host, ca_certs=False, verify_certs=False)
print(es)
doc = {
'author': 'kimchy',
'text': 'Elasticsearch: cool. bonsai cool.',
'timestamp': datetime.now(),
}
resp = es.index(index="test-index", id=1, document=doc)
print(resp['result'])
resp = es.get(index="test-index", id=1)
print(resp['_source'])elasticsearch文档中的内容
FROM docker.elastic.co/elasticsearch/elasticsearch:7.12.0
RUN elasticsearch-plugin install --batch https://github.com/alexklibisz/elastiknn/releases/download/7.12.0.0/elastiknn-7.12.0.0.zipurllib3==1.26.9 requests==2.27.1
发布于 2022-07-11 06:12:51
您应该将"https“更改为"http”,这是答案。
发布于 2022-08-08 12:36:26
#disable certificate
es = Elasticsearch(hosts="https://localhost:9200", basic_auth=(USER, PASS), verify_certs=False)
#if getting an issue relevant to the certificate then:
es = Elasticsearch(hosts="https://localhost:9200", basic_auth=(USER, PASS), ca_certs=CERTIFICATE, verify_certs=False)
# I hope you know where to find certificateReference 继续了解更多信息
发布于 2022-07-19 03:44:09
您必须检查是否正确设置了scheme,也就是说,如果https是为运行弹性的本地主机编写的,而不是http,则会产生此错误。
如果弹性只在http上运行,下面的代码将引发TLS错误。
es = Elasticsearch([{'host': 'localhost', 'port':9200, 'scheme':'https'}])解决这一问题的正确方法应该是重新配置TLS,使其同时侦听https和http,或者简单地使用当前运行弹性节点的正确方案名称。
更正代码应是:
es = Elasticsearch([{'host': 'localhost', 'port':9200, 'scheme':'http'}])https://stackoverflow.com/questions/71805911
复制相似问题