Бить: Ошибка подключения: Ошибка при чтении из сокета: (104, 'Connection reset by peer')
Я развертываю свой Django backend на Heroku и использую celery и Redis в качестве брокера. Но я получаю эти ошибки в журнале рабочих операций:
2021-08-23T17:43:05.148602+00:00 app[worker.1]: [2021-08-23 17:43:05,148: ERROR/Beat] beat: Connection error: Error while reading from socket: (104, 'Connection reset by peer'). Trying again in 32.0 seconds...
2021-08-23T17:43:35.862615+00:00 app[worker.1]: [2021-08-23 17:43:35,862: ERROR/MainProcess] consumer: Cannot connect to redis://:**@ec2-52-22-18-101.compute-1.amazonaws.com:30320//: Error while reading from socket: (104, 'Connection reset by peer').
2021-08-23T17:43:35.862624+00:00 app[worker.1]: Trying again in 32.00 seconds... (16/100)
setting.py:
CELERY_BROKER_URL = 'redis://:*******.compute-1.amazonaws.com:port'
CELERY_RESULT_BACKEND = 'redis://:***********.compute-1.amazonaws.com:port'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TASK_SELERLIZER = 'json'
CELERY_TIMEZONE = 'Asia/Kolkata'
BROKER_POOL_LIMIT = None
celery.py :
from __future__ import absolute_import
from datetime import timezone
import os
from celery import Celery
from django.conf import settings
from celery.schedules import crontab, schedule
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'NewsApi.settings')
app = Celery('NewsApi')
app.conf.beat_schedule = {
'add-every-1-hour': {
'task': 'Api.tasks.task_news_update',
'schedule': crontab(minute=0, hour='*/1'),
}
}
app.conf.update(timezone = 'Asia/Kolkata')
# Using a string here means the worker will not have to
# pickle the object when using Windows.
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
@app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))