簡體   English   中英

芹菜沒有連接到Redis

[英]Celery not connecting to Redis

我正在一個 Django 項目中工作,我正在嘗試將 celery 集成到我的項目中,但我的應用程序似乎無法連接到我在本地運行的 redis 服務器。

這就是我運行 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..

我注意到傳輸中的 url 不是我的本地主機,我不知道它是在哪里設置的。 我正在使用 celery 4.3.0,redis 3.2.1。

在我的 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()

在我的設置中,我有

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

這絕對是配置問題。 您的 settings.py、celery.py 或環境中的某些內容正在覆蓋您的代理以指向redis://34.202.114.79

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM