当前位置:  开发笔记 > 编程语言 > 正文

Boto3中的异常 - botocore.exceptions.EndpointConnectionError

如何解决《Boto3中的异常-botocore.exceptions.EndpointConnectionError》经验,为你挑选了1个好方法。

尝试使用此python代码连接到数据库以测试连接时.

import boto3
s3 = boto3.resource('s3')

for b in s3.buckets.all():
   print b.name

我收到了这个错误.

Traceback (most recent call last):
  File "boto3_test.py", line 4, in 
    for b in s3.buckets.all():
  File "/usr/local/lib/python2.7/dist-packages/boto3/resources/collection.py", line 83, in __iter__
    for page in self.pages():
  File "/usr/local/lib/python2.7/dist-packages/boto3/resources/collection.py", line 161, in pages
    pages = [getattr(client, self._py_operation_name)(**params)]
  File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 310, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 385, in _make_api_call
    operation_model, request_dict)
  File "/usr/local/lib/python2.7/dist-packages/botocore/endpoint.py", line 111, in make_request
    return self._send_request(request_dict, operation_model)
  File "/usr/local/lib/python2.7/dist-packages/botocore/endpoint.py", line 140, in _send_request
    success_response, exception):
  File "/usr/local/lib/python2.7/dist-packages/botocore/endpoint.py", line 213, in _needs_retry
    caught_exception=caught_exception)
  File "/usr/local/lib/python2.7/dist-packages/botocore/hooks.py", line 226, in emit
    return self._emit(event_name, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/botocore/hooks.py", line 209, in _emit
    response = handler(**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/botocore/retryhandler.py", line 183, in __call__
    if self._checker(attempts, response, caught_exception):
  File "/usr/local/lib/python2.7/dist-packages/botocore/retryhandler.py", line 250, in __call__
    caught_exception)
  File "/usr/local/lib/python2.7/dist-packages/botocore/retryhandler.py", line 273, in _should_retry
    return self._checker(attempt_number, response, caught_exception)
  File "/usr/local/lib/python2.7/dist-packages/botocore/retryhandler.py", line 313, in __call__
    caught_exception)
  File "/usr/local/lib/python2.7/dist-packages/botocore/retryhandler.py", line 222, in __call__
    return self._check_caught_exception(attempt_number, caught_exception)
  File "/usr/local/lib/python2.7/dist-packages/botocore/retryhandler.py", line 355, in _check_caught_exception
    raise caught_exception
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://s3.us-east-5.amazonaws.com/"

奇怪的是,连接在当天早些时候工作,然后在它停止工作同样的事情发生在我昨天同时所以我假设这是一个网络配置问题.这个问题是唯一与原始海报所说的解决方案类似的解决方案,即取消设置HTTP_PROXY和HTTPS_PROXY但我没有尝试.



1> helloV..:

您已正确配置AWS env.检查你的~/.aws/config文件.您必须将其错误地配置为us-east-5,这是一个无效区域.将其更改为us-east-1.或者aws configure再次运行命令并指定正确的区域.

[default]
region = us-east-1


@ vishal.k最有可能的是Boto3正在从其他地方进入该地区。检查是否在环境变量`AWS_DEFAULT_REGION`中配置了区域(如果已设置),请取消设置该区域,然后重试。请参阅:http://boto3.readthedocs.io/en/latest/guide/configuration.html
推荐阅读
刘美娥94662
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有