question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ProxyConnectionError when specify username and password

See original GitHub issue

Please fill out the sections below to help us address your issue.

What issue did you see ? I try to connect to proxy server that need to provide username/password Method 1:

s3_client = boto3.client(
    's3',
    region_name = aws_region,
    aws_access_key_id=credentials['accessKeyId'],
    aws_secret_access_key=credentials['secretAccessKey'],
    aws_session_token=credentials['sessionToken'],
    config=Config(proxies={'https': "<username>:<password>@<proxy host>:<proxy port>"})
)

Methon 2:

use os.environ["HTTPS_PROXY"] = "http://<username>:<password>@<proxy host>:<proxy port>"

But always got this exception:

Traceback (most recent call last):                                                                                         
    s3_client.delete_object (
  File "/myhome/cdp_python36_venv/lib/python3.8/site-packages/botocore/client.py", line 391, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/myhome/cdp_python36_venv/lib/python3.8/site-packages/botocore/client.py", line 705, in _make_api_call
    http, parsed_response = self._make_request(
  File "/myhome/cdp_python36_venv/lib/python3.8/site-packages/botocore/client.py", line 725, in _make_request
    return self._endpoint.make_request(operation_model, request_dict)
  File "/myhome/cdp_python36_venv/lib/python3.8/site-packages/botocore/endpoint.py", line 104, in make_request
    return self._send_request(request_dict, operation_model)
  File "/myhome/cdp_python36_venv/lib/python3.8/site-packages/botocore/endpoint.py", line 138, in _send_request
    while self._needs_retry(attempts, operation_model, request_dict,
  File "/myhome/cdp_python36_venv/lib/python3.8/site-packages/botocore/endpoint.py", line 254, in _needs_retry
    responses = self._event_emitter.emit(
  File "/myhome/cdp_python36_venv/lib/python3.8/site-packages/botocore/hooks.py", line 357, in emit
    return self._emitter.emit(aliased_event_name, **kwargs)
  File "/myhome/cdp_python36_venv/lib/python3.8/site-packages/botocore/hooks.py", line 228, in emit
    return self._emit(event_name, kwargs)
  File "/myhome/cdp_python36_venv/lib/python3.8/site-packages/botocore/hooks.py", line 211, in _emit
    response = handler(**kwargs)
  File "/myhome/cdp_python36_venv/lib/python3.8/site-packages/botocore/retryhandler.py", line 183, in __call__
    if self._checker(attempts, response, caught_exception):
  File "/myhome/cdp_python36_venv/lib/python3.8/site-packages/botocore/retryhandler.py", line 250, in __call__
    should_retry = self._should_retry(attempt_number, response,
  File "/myhome/cdp_python36_venv/lib/python3.8/site-packages/botocore/retryhandler.py", line 277, in _should_retry
    return self._checker(attempt_number, response, caught_exception)
  File "/myhome/cdp_python36_venv/lib/python3.8/site-packages/botocore/retryhandler.py", line 316, in __call__
    checker_response = checker(attempt_number, response,
  File "/myhome/cdp_python36_venv/lib/python3.8/site-packages/botocore/retryhandler.py", line 222, in __call__
    return self._check_caught_exception(
  File "/myhome/cdp_python36_venv/lib/python3.8/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
    raise caught_exception
  File "/myhome/cdp_python36_venv/lib/python3.8/site-packages/botocore/endpoint.py", line 201, in _do_get_response
    http_response = self._send(request)
  File "/myhome/cdp_python36_venv/lib/python3.8/site-packages/botocore/endpoint.py", line 270, in _send
    return self.http_session.send(request)
  File "/myhome/cdp_python36_venv/lib/python3.8/site-packages/botocore/httpsession.py", line 416, in send
    raise ProxyConnectionError(proxy_url=proxy_url, error=e)
botocore.exceptions.ProxyConnectionError: Failed to connect to proxy URL: "http://<username>:<password>@<proxy host>:<proxy port>"

Seems http://<username>:<password>@<proxy host>:<proxy port> is not a valid URL, so it fails. Is there anything missing in my sample code? And I found Java SDK to specify proxy username/password like:

ClientConfiguration clientConfig = new ClientConfiguration()
    .withSocketTimeout(60000)
    .withConnectionTimeout(60000)
    .withProxyProtocol(Protocol.HTTP)
    .withProxyHost(proxyHost)
    .withProxyPort(proxyPort)
    .withProxyUsername("athens")
    .withProxyPassword(athenzCred)

Can boto3 provide silimiar APIs?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
bradhill99commented, Feb 2, 2022

Found the issue, can close this one. thanks.

0reactions
francescogabbriellicommented, Jul 11, 2022

Hi @Javi2255

I guess the credentials were wrong

Read more comments on GitHub >

github_iconTop Results From Across the Web

What if password has an '@' when using command line proxy ...
[SOLVED] I had to ask the user to change the password and then it worked out.
Read more >
Using an HTTP proxy - AWS Command Line Interface
The AWS CLI supports HTTP Basic authentication. Specify the user name and password in the proxy URL, as follows.
Read more >
1Password keeps asking for proxy credentials
Everytime 1Password starts I get a pop up dialog to enter my proxy user/password: Authentication required. The server proxy such_and_such is ...
Read more >
How do I set a system wide proxy with a username and ...
After selecting the tab, select the Method to be manual and set all the proxies. Then, click Apply system wide , it will...
Read more >
Proxyconnectionerror When Connecting As Anonymous - ADocLib
... are set when you submit a form login or interact with the site by. ... lets a user bind to the directory...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found