celery 未连接到redis

piztneat  于 2021-06-09  发布在  Redis
关注(0)|答案(1)|浏览(544)

我在django项目中工作,我试图将celery 集成到我的项目中,但我的应用程序似乎无法连接到我在本地运行的redis服务器。
这是当我经营celery 时它给我看的-一个项目工人。

----****----- 
---***** -- Linux-4.15.0-58-generic-x86_64-with-Ubuntu-18.04-bionic 2020-03-18 19:06:29
-- * -****--- 
-**---------- [config]
-**---------- .> app:         proyecto_is2:0x7f7c98351518
-**---------- .> transport:   redis://h:**@ec2-34-202-114-79.compute-1.amazonaws.com:17729//
-**---------- .> results:     redis://127.0.0.1:6379/0
-***--- * --- .> concurrency: 8 (prefork)
--*******---- .> task events: OFF (enable -E to monitor tasks in this worker)
---*****----- 
-------------- [queues]
            .> celery           exchange=celery(direct) key=celery
[2020-03-18 19:31:24,595: ERROR/MainProcess] consumer: Cannot connect to
redis://h:**@ec2-34-202-114-79.compute-1.amazonaws.com:17729//: Error 110 connecting to
ec2-34-202-114-79.compute-1.amazonaws.com:17729. Connection timed out..

我注意到传输中的url不是我的localhost,我不知道在哪里设置的。我用的是celery 4.3.0,redis 3.2.1。
在我的celery 里

import os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proyecto_is2.settings.dev_settings')
app = Celery('proyecto_is2')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()

在我的环境中我有

... other configs
CELERY_BROKER_URL = 'redis://127.0.0.1:6379'
CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TASK_SERIALIZER = 'json'
wqnecbli

wqnecbli1#

这绝对是一个配置问题。settings.py、celery.py或环境中的某些内容正在重写您的代理以指向 redis://34.202.114.79 .

相关问题