3

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)
mlablablab
  • 220
  • 2
  • 9
  • I feel like this is because the server is expecting ssl but the client is not using it. – Rickkwa Sep 25 '21 at 02:00
  • 1
    @mlablablab Did you try using an older version of the client? See https://github.com/elastic/elasticsearch-py/pull/1623 for reference. – Empty Space Sep 26 '21 at 08:51
  • 1
    @MutableSideEffect thanks for the pull request link. Did some more digging. Here are the supported libraries https://opensearch.org/docs/clients/index/ and this is a solution to this https://github.com/opendistro-for-elasticsearch/sample-code/issues/242 – mlablablab Sep 26 '21 at 22:36

0 Answers0