【问题标题】:AWS EndPoint connection error using python使用 python 的 AWS EndPoint 连接错误
【发布时间】:2019-01-31 06:00:24
【问题描述】:

我看过一些帖子,并且配置文件存在端点连接问题,但似乎我的配置文件没问题,仍然面临问题 我的 .aws/config 文件

[default]
aws_access_key_id=XXX
aws_secret_access_key=XXX
region=ap-south-1
output = text


>>> import boto3
>>> translate = boto3.client(service_name='translate',region_name='ap-south-1', use_ssl=True)
>>> result = translate.translate_text(Text="Hello, World", 
            SourceLanguageCode="en", TargetLanguageCode="de")


Traceback (most recent call last):
  File "<pyshell#2>", line 2, in <module>
    SourceLanguageCode="en", TargetLanguageCode="de")
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/client.py", line 314, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/client.py", line 599, in _make_api_call
    operation_model, request_dict)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/endpoint.py", line 148, in make_request
    return self._send_request(request_dict, operation_model)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/endpoint.py", line 177, in _send_request
    success_response, exception):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/endpoint.py", line 273, in _needs_retry
    caught_exception=caught_exception, request_dict=request_dict)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/hooks.py", line 227, in emit
    return self._emit(event_name, kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/hooks.py", line 360, in _emit
    aliased_event_name, kwargs, stop_on_response
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/hooks.py", line 210, in _emit
    response = handler(**kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/retryhandler.py", line 183, in __call__
    if self._checker(attempts, response, caught_exception):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/retryhandler.py", line 251, in __call__
    caught_exception)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/retryhandler.py", line 277, in _should_retry
    return self._checker(attempt_number, response, caught_exception)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/retryhandler.py", line 317, in __call__
    caught_exception)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/retryhandler.py", line 223, in __call__
    attempt_number, caught_exception)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
    raise caught_exception
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://translate.ap-south-1.amazonaws.com/"
>>> 

我使用 AdministratorAccess 创建了 IAM 用户

【问题讨论】:

  • 配置文件存放在哪个文件夹?

标签: python-3.x amazon-web-services amazon-s3 amazon-ec2 aws-sdk


【解决方案1】:

Amazon Translate 在 ap-south-1(孟买)区域不可用。这就是 boto3 无法连接到端点的原因。您需要选择支持的区域。

请参阅此链接以获取当前支持的地区列表: Amazon Translate Supported Regions

【讨论】:

    【解决方案2】:

    当我的连接中断时,我遇到了同样的错误 - botocore.exceptions.EndpointConnectionError:无法连接到端点 URL:“https://ec2.us-east-2.amazonaws.com/”

    连接恢复后,它可以正常工作。此错误的可能原因可能是

    连接错误 区域无法满足您的请求,因为每个请求都会到达 AWS 上的端点(更多详细信息可以在 https://docs.aws.amazon.com/general/latest/gr/rande.html#billing-pricing 上找到) 似乎 Boto3 已经成熟到足以抛出异常,因为更恰当的原因是无法准确知道发生了什么。

    此外,如果您有任何与您的配置相关的问题,那么它们中的大多数都被封装了 ClientError 异常。

    【讨论】:

      猜你喜欢
      • 2017-09-07
      • 2023-04-09
      • 1970-01-01
      • 2020-12-14
      • 2020-06-29
      • 2021-01-20
      • 2018-10-30
      • 2020-09-22
      • 1970-01-01
      相关资源
      最近更新 更多