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] The proxy setup does not work with Urllib3HttpConnection #821

Open
int0x03 opened this issue Sep 16, 2024 · 6 comments
Open

[BUG] The proxy setup does not work with Urllib3HttpConnection #821

int0x03 opened this issue Sep 16, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@int0x03
Copy link

int0x03 commented Sep 16, 2024

What is the bug?

the proxy setup in this wiki does not work https://github.com/opensearch-project/opensearch-py/blob/main/guides/proxy.md

How can one reproduce the bug?

use the code in wiki

What is the expected behavior?

follow the wiki, the proxy should work

What is your host/environment?

MAC

Do you have any screenshots?

no

Do you have any additional context?

no

@int0x03 int0x03 added bug Something isn't working untriaged Need triage labels Sep 16, 2024
@florian-lang-a1
Copy link

If you are using the code for the Sync Client there is actually a line missing there.
It should be

from opensearchpy import OpenSearch, RequestsHttpConnection

OpenSearch(
    hosts=["https://..."],
    use_ssl=True,
    verify_certs=True,
    connection_class=RequestsHttpConnection,
    trust_env=True,
)

@dblock
Copy link
Member

dblock commented Sep 17, 2024

@int0x03 @florian-lang-a1 care to help fix the doc please?

@dblock dblock removed the untriaged Need triage label Sep 17, 2024
@int0x03
Copy link
Author

int0x03 commented Sep 19, 2024

thanks @florian-lang-a1 @dblock .
with @florian-lang-a1 suggestion, it means we must setup the proxy in environment variables right? if yes, it means the proxy is used by all the client connection code. that's the not correct way.

it is better to have a proxies parameter, like the python requests:

import requests

proxies = {
    'http': 'http://proxy.example.com:8080',
    'https': 'http://proxy.example.com:8080',
}

response = requests.get('http://example.com', proxies=proxies)
print(response.text)

@dblock
Copy link
Member

dblock commented Sep 19, 2024

it is better to have a proxies parameter, like the python requests:

Yes, you're correct.

@int0x03
Copy link
Author

int0x03 commented Sep 19, 2024

I will check how to add this parameter and send a PR in the weekend.

@dblock
Copy link
Member

dblock commented Oct 23, 2024

Looks like RequestsHttpConnection works for the proxy scenario but not Urllib3HttpConnection. This is the bug that needs to be fixed.

@dblock dblock changed the title [BUG] the proxy not work [BUG] The proxy setup does not work with Urllib3HttpConnection Oct 23, 2024
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