Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Cannot connect to a Docker local development cluster using opensearch-py #193

Closed
dylanjcastillo opened this issue Aug 30, 2022 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@dylanjcastillo
Copy link

What is the bug?

I cannot connect to a local development cluster using opensearch-py. If I use curl it works correctly.

How can one reproduce the bug?

  1. Run Docker's image for local development: docker run -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" opensearchproject/opensearch:2.2.0
  2. Run the following code in python:

host = 'localhost'
port = 9200
auth = ('admin', 'admin')

client = OpenSearch(
    hosts = [{'host': host, 'port': port}],
    http_auth = auth,
    use_ssl = False,
    verify_certs = False,
    ssl_assert_hostname = False,
    ssl_show_warn = False,
)
client.info()

What is the expected behavior?

I should get info about the cluster.

What is your host/environment?

      Model Name: MacBook Air
      Chip: Apple M1
      Total Number of Cores: 8 (4 performance and 4 efficiency)
      Memory: 16 GB
      System Version: macOS 12.5.1 (21G83)
      Kernel Version: Darwin 21.6.0

Do you have any screenshots?

It works well when I use curl: https://imgur.com/a/0O15MaM

Do you have any additional context?

Here's the error I get in the Jupyter Notebook:

ConnectionError: ConnectionError(('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))) caused by: ProtocolError(('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))

Here's the error I get in the terminal running the cluster:

[2022-08-30T13:56:34,254][ERROR][o.o.s.s.h.n.SecuritySSLNettyHttpServerTransport] [db120fd1fe80] Exception during establishing a SSL connection: io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record: 
@dylanjcastillo dylanjcastillo added bug Something isn't working untriaged Need triage labels Aug 30, 2022
@dtaivpp
Copy link

dtaivpp commented Aug 30, 2022

Hey @dylanjcastillo you need to set use_ssl to true and then the rest should be correct. By default the container forces SSL even though it’s using self signed certs.

@dtaivpp dtaivpp removed the untriaged Need triage label Aug 30, 2022
@dtaivpp dtaivpp self-assigned this Aug 30, 2022
@dtaivpp
Copy link

dtaivpp commented Aug 30, 2022

Let me know if you still have issues after you try that.

@dylanjcastillo
Copy link
Author

That was it! Thank you, it's working now.

@dtaivpp
Copy link

dtaivpp commented Aug 30, 2022

Awesome! It’s a pretty common issue with the client. I actually wonder if we could raise a specific exception to alert people to try and change the verify setting

@dtaivpp dtaivpp closed this as completed Aug 30, 2022
@wbeckler
Copy link
Contributor

Would either of you be up for creating an issue to change this default, and/or to drafting a PR?

@dylanjcastillo
Copy link
Author

Hey @wbeckler, yes, I'd be happy to! Seems like a good first issue to contribute

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants