我使用boto3连接到AWS的代码出错。错误刚刚在昨天下午开始,在我最后一次没有收到错误之间,第一次出现错误时我没有看到任何变化。
错误是:
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL:
在.aws / config中我有:
$ cat ~/.aws/config
[default]
region=us-east-1
以下是我所知道的:
我不认为我在上一次工作和第一次工作之间改变了会影响这一点的任何事情。我似乎不得不在我这边或某些低级库中更改某些AWS特定配置,而且我没有做出任何此类更改。我和一位同事谈了30-45分钟,当我回来并从我离开的地方回来时,问题首次出现。
有关解决此问题的任何想法或想法?
完全例外转储。
$ python
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto3
>>> boto3.client('ec2').describe_regions()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/botocore/client.py", line 200, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/Library/Python/2.7/site-packages/botocore/client.py", line 244, in _make_api_call
operation_model, request_dict)
File "/Library/Python/2.7/site-packages/botocore/endpoint.py", line 173, in make_request
return self._send_request(request_dict, operation_model)
File "/Library/Python/2.7/site-packages/botocore/endpoint.py", line 203, in _send_request
success_response, exception):
File "/Library/Python/2.7/site-packages/botocore/endpoint.py", line 267, in _needs_retry
caught_exception=caught_exception)
File "/Library/Python/2.7/site-packages/botocore/hooks.py", line 226, in emit
return self._emit(event_name, kwargs)
File "/Library/Python/2.7/site-packages/botocore/hooks.py", line 209, in _emit
response = handler(**kwargs)
File "/Library/Python/2.7/site-packages/botocore/retryhandler.py", line 183, in __call__
if self._checker(attempts, response, caught_exception):
File "/Library/Python/2.7/site-packages/botocore/retryhandler.py", line 250, in __call__
caught_exception)
File "/Library/Python/2.7/site-packages/botocore/retryhandler.py", line 273, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "/Library/Python/2.7/site-packages/botocore/retryhandler.py", line 313, in __call__
caught_exception)
File "/Library/Python/2.7/site-packages/botocore/retryhandler.py", line 222, in __call__
return self._check_caught_exception(attempt_number, caught_exception)
File "/Library/Python/2.7/site-packages/botocore/retryhandler.py", line 355, in _check_caught_exception
raise caught_exception
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://ec2.us-east-1.amazonaws.com/"
答案 0 :(得分:4)
问题已解决。事实证明,一些看似无关的动作独立于任何与boto相关的行为导致HTTP_PROXY和HTTPS_PROXY环境变量设置不正确,然后在boto3和aws cli下打破了botocore调用。删除这两个环境变量解决了这个问题。
我会把它留下来,因为我发现很难找到任何指向这个错误的可能原因。可能会拯救别人一些我经过的头发。
答案 1 :(得分:0)
我刚才有类似的问题。突然之间,在django上我的s3到boto3的连接不再可能,而我仍然可以在我的Heroku环境中执行操作。
出现我最近安装了amazon CLI,我的配置不同,CLI取代环境变量......该死的。我花了3个小时才找到。
通过aws configure
我现在设置
AWS Access Key ID [****************MPIA]: "your true key here without quotes"
AWS Secret Access Key [****************7DWm]: "your true secret access key here without quotes"
Default region name [eu-west-1]: "your true region here without quotes"
Default output format [None]: [here i did just an enter in order not to change this]
只是为了有这个问题的人发布这个。
答案 2 :(得分:0)
我在连接中断时遇到了同样的错误 - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://ec2.us-east-2.amazonaws.com/"
当连接恢复后,它就可以正常工作了。此错误的可能原因是
似乎 Boto3 已经足够成熟,可以抛出异常以获取更正确的失败原因,无法准确了解正在发生的事情。
此外,如果您有任何与配置相关的问题,那么大多数问题都封装在 ClientError 异常中。