【问题标题】:boto SQS NoSuchVersion Errorboto SQS NoSuchVersion 错误
【发布时间】:2013-12-14 00:07:53
【问题描述】:

以下脚本最好地描述了我的问题:

import boto
boto.__version__
# OUT: '2.19.0'
from boto.ec2.connection import EC2Connection
ec2 = EC2Connection(**creds)
regions = ec2.get_all_regions()
from boto.sqs.connection import SQSConnection
regions[0]
# OUT: RegionInfo:eu-west-1
sqs = SQSConnection(region=regions[0], **creds)
sqs.get_all_queues()
# OUT: Traceback (most recent call last):
# OUT:   File "<input>", line 1, in <module>
# OUT:   File "/opt/zenoss/lib/python2.7/site-packages/boto/sqs/connection.py", line 338, in get_all_queues
# OUT:     return self.get_list('ListQueues', params, [('QueueUrl', Queue)])
# OUT:   File "/opt/zenoss/lib/python2.7/site-packages/boto/connection.py", line 1119, in get_list
# OUT:     raise self.ResponseError(response.status, response.reason, body)
# OUT: SQSError: SQSError: 400 Bad Request
# OUT: <?xml version="1.0" encoding="UTF-8"?>
# OUT: <Response><Errors><Error><Code>NoSuchVersion</Code><Message>The requested version (2012-11-05) of service AmazonEC2 does not exist</Message></Error></Errors><RequestID>1600907e-6780-46f5-b5e6-e647a660abf8</RequestID></Response>

我找不到有关此错误含义以及如何修复它的 AWS 或 boto 文档。这是boto的bug吗?

【问题讨论】:

    标签: python amazon-ec2 boto amazon-sqs


    【解决方案1】:

    上述代码的问题在于,来自 EC2 模块的 get_all_regions() 调用返回了由区域名称和区域端点组成的 RegionInfo 对象列表。但端点用于 EC2 服务,而不是 SQS。因此,如果您将 RegionInfo 传递给 SQSConnection 构造函数,它最终会尝试针对 EC2 端点发出 SQS 请求,从而导致 NoSuchVersion 错误。

    我会这样做:

    import boto.sqs
    
    sqs = boto.sqs.connect_to_region('eu-west-1')
    sqs.get_all_queues()
    

    同样,如果您需要 EC2 连接:

    import boto.ec2
    
    ec2 = boto.ec2.connect_to_region('eu-west-1')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多