I am trying to get a python ElasticSearch client to connect to a local OpenSearch server that is running via docker. Am unable to connect and keep getting

opensearch-node1       | [2021-09-25T00:09:09,526][ERROR][o.o.s.s.h.n.SecuritySSLNettyHttpServerTransport] [opensearch-node1] Exception during establishing a SSL connection: io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record:

Installed OpenSearch locally sing docker following these instructions https://opensearch.org/downloads.html

Tried various ways to get the python client to connect but all are failing.

# es = Elasticsearch(timeout=600, hosts="http://localhost:9200", http_auth=('admin', 'admin'), use_ssl=False, verify_certs=False)
es = Elasticsearch(timeout=600, hosts=["http://localhost:9200"])
es.ping()

python version: 3.9.7

ElasticSearch python lib: 7.15.0

Has anybody experiences this?

**** Figured it out ****

Need to have a client of at most 7.13.4 as per the docs opensearch.org/docs/clients/index

and as per this issues github.com/opendistro-for-elasticsearch/sample-code/issues/242, have to initiate the client like this for local dev

es = Elasticsearch(['https://admin:admin@localhost:9200/'], 
                   use_ssl=False,
                   verify_certs=False,
                   ssl_show_warn=False)
0

There are 0 best solutions below