简体   繁体   English

芹菜没有连接到Redis

[英]Celery not connecting to Redis

I'm working in a Django project and i'm trying to integrate celery into my project but my app doesn't seem to be able to connect to my redis-server that I'm running locally.我正在一个 Django 项目中工作,我正在尝试将 celery 集成到我的项目中,但我的应用程序似乎无法连接到我在本地运行的 redis 服务器。

This is what it shows me when I run celery -A project worker.这就是我运行 celery -A project worker 时显示的内容。

---- **** ----- 
--- * ***  * -- 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..

I noticed that the url in transport is not my localhost and I don't know where that got set up.我注意到传输中的 url 不是我的本地主机,我不知道它是在哪里设置的。 I'm using celery 4.3.0, redis 3.2.1.我正在使用 celery 4.3.0,redis 3.2.1。

In my celery.py I have在我的 celery.py 中,我有

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()

In my settings i have在我的设置中,我有

... 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'

This is definitely a config issue.这绝对是配置问题。 Something either in your settings.py, celery.py, or environment is overriding your broker to point to redis://34.202.114.79 .您的 settings.py、celery.py 或环境中的某些内容正在覆盖您的代理以指向redis://34.202.114.79

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM