Celery 4.0.0 + Amazon SQS - > "凭据应限定在有效区域,而不是排队'队列'。

时间:2016-12-09 13:55:57

标签: python django celery

我在Django应用程序中使用SQS运行Celery:

当我在代理设置中指定区域时:

CELERY_BROKER_URL = 'sqs://'
CELERY_BROKER_TRANSPORT_OPTIONS = {
    'region': 'eu-west-1',
    'polling_interval': 3,
    'visibility_timeout': 300,
    'queue_name_prefix':'dev-celery-',
}

我可以看到在Amazon SQS中创建的队列,但同时我尝试启动工作时出现以下错误。

[2016-12-09 16:06:41,206: WARNING/MainProcess] consumer: Connection to broker lost. Trying to re-establish the connection...
Traceback (most recent call last):
File "/home/ubuntu/virtualenvs/env/lib/python3.5/site-packages/celery/worker/consumer/consumer.py", line 318, in start
blueprint.start(self)
File "/home/ubuntu/virtualenvs/env/lib/python3.5/site-packages/celery/bootsteps.py", line 119, in start
step.start(parent)
File "/home/ubuntu/virtualenvs/env/lib/python3.5/site-packages/celery/worker/consumer/consumer.py", line 584, in start
c.loop(*c.loop_args())
File "/home/ubuntu/virtualenvs/env/lib/python3.5/site-packages/celery/worker/loops.py", line 88, in asynloop
next(loop)
File "/home/ubuntu/virtualenvs/env/lib/python3.5/site-packages/kombu/async/hub.py", line 345, in create_loop
cb(*cbargs)
File "/home/ubuntu/virtualenvs/env/lib/python3.5/site-packages/kombu/async/http/curl.py", line 111, in on_readable
return self._on_event(fd, _pycurl.CSELECT_IN)
File "/home/ubuntu/virtualenvs/env/lib/python3.5/site-packages/kombu/async/http/curl.py", line 124, in _on_event
self._process_pending_requests()
File "/home/ubuntu/virtualenvs/env/lib/python3.5/site-packages/kombu/async/http/curl.py", line 130, in _process_pending_requests
self._process(curl)
File "/home/ubuntu/virtualenvs/env/lib/python3.5/site-packages/kombu/async/http/curl.py", line 178, in _process
buffer=buffer, effective_url=effective_url, error=error,
File "/home/ubuntu/virtualenvs/env/lib/python3.5/site-packages/vine/promises.py", line 146, in call
svpending(*ca, **ck)
File "/home/ubuntu/virtualenvs/env/lib/python3.5/site-packages/vine/promises.py", line 139, in call
return self.throw()
File "/home/ubuntu/virtualenvs/env/lib/python3.5/site-packages/vine/promises.py", line 136, in call
retval = fun(*final_args, **final_kwargs)
File "/home/ubuntu/virtualenvs/env/lib/python3.5/site-packages/vine/funtools.py", line 100, in _transback
return callback(ret)
File "/home/ubuntu/virtualenvs/env/lib/python3.5/site-packages/vine/promises.py", line 139, in call
return self.throw()
File "/home/ubuntu/virtualenvs/env/lib/python3.5/site-packages/vine/promises.py", line 136, in call
retval = fun(*final_args, **final_kwargs)
File "/home/ubuntu/virtualenvs/env/lib/python3.5/site-packages/vine/funtools.py", line 98, in _transback
callback.throw()
File "/home/ubuntu/virtualenvs/env/lib/python3.5/site-packages/vine/funtools.py", line 96, in transback
ret = filter(*args + (ret,), **kwargs)
File "/home/ubuntu/virtualenvs/env/lib/python3.5/site-packages/kombu/async/aws/connection.py", line 269, in _on_list_ready
raise self._for_status(response, body)
boto.exception.SQSError: SQSError: 403 Forbidden
SenderSignatureDoesNotMatchCredential should be scoped to a valid region, not 'queue'.
[2016-12-09 16:06:41,260: INFO/MainProcess] Connected to sqs://localhost//

它可能是Celery中的一个错误,所以我创建了一个issue at git。 我的猜测是Celery使用传统端点进行SQS。新端点被描述为at Amazon

如果不是这样,请发布您的解决方案!

1 个答案:

答案 0 :(得分:0)

我找到了答案here

Bug与boto中未更新的endpoints.json有关。 Pull request已创建但尚未合并。

作为一种解决方法,可以为boto加载个人endpoints.json文件。为此,您应该在BOTO_ENDPOINTS环境变量中指定文件的路径,并从pull请求加载更正的文件。

在校正端点后,我解决了这个问题。