没有明显原因的python boto3连接错误 [英] python boto3 connection error with no apparent cause

查看:345
本文介绍了没有明显原因的python boto3连接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用boto3连接到AWS的代码遇到错误。错误刚从昨天下午开始,在上一次我没有收到错误和第一次我得到错误之间,我看不到任何变化。

I'm hitting an error with code that connects to AWS using boto3. The error just started yesterday afternoon, and between the last time I didn't get the error and the first time I got the error I don't see anything that changed.

错误是:

botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL:

在.aws / config中,我有:

In .aws/config I have:

$ cat ~/.aws/config
[default]
region=us-east-1

这是我所知道的:


  • 在另一台计算机上使用相同的AWS凭证和配置,我不知道没看到错误。

  • 在同一台计算机上使用不同的AWS凭证和配置,我确实看到了错误。

  • 我是唯一的错误在我们的小组中,对于任何计算机上的所有凭据都存在此问题。

我认为我没有更改任何会影响此权限的内容上一次有效,第一次无效。似乎我不得不在我这边更改某些特定于AWS的配置或一些底层库,而我没有进行任何此类更改。我和一位同事交谈了30-45分钟,当我返回并拿起我离开的地方时,这个问题才第一次出现。

I don't think I changed anything that would affect this between the last time this worked and the first time it didn't. It seems like I'd have had to change some AWS specific configuration on my side or some low level libraries, and I didn't make any such change. I was talking with a colleague for 30-45 minutes and when I returned and picked up where I left off the issue first appeared.

对解决此问题有任何想法或想法吗?

Any thoughts or ideas on troubleshooting this?

随后是完全异常转储。

$ 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/"


推荐答案

问题已解决。事实证明,独立于boto相关内容的几个看似无关的动作导致HTTP_PROXY和HTTPS_PROXY环境变量的设置不正确,从而破坏了boto3和aws cli下的botocore调用。删除两个环境变量都可以解决问题。

Issue resolved. It turns out that a couple of seemingly unrelated actions independent of anything boto related resulted in HTTP_PROXY and HTTPS_PROXY environment variables being improperly set, which was then breaking the botocore calls under both boto3 and the aws cli. Removing both environment variables resolved the problem.

我将不做说明,因为发现很难找到任何指向此错误的原因。可能会省去别人一些我经历过的头发。

I'll leave this up as I found it very difficult to find anything pointing to this as a possible cause of this error. Might save someone else some of the hair pulling I went through.

这篇关于没有明显原因的python boto3连接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆