Search code examples
pythondjangorabbitmqcelerycloudamqp

consumer: Cannot connect to amqp://dfmngfek:**@salamander.rmq.cloudamqp.com:5672/dfmngfek: [Errno 104] Connection reset by peer


My site runs with Python 3.5.6, Django 1.11.20, Celery 4.3.0, CloudAMQP (through Heroku), based on RabbitMQ. Celery returns the following error when the app is deployed to Heroku:

consumer: Cannot connect to amqp://dfmngfek:*@salamander.rmq.cloudamqp.com:5672/dfmngfek: [Errno 104] Connection reset by peer

I can't find where does this issue come from.

Here are my settings:

CELERY_BROKER_POOL_LIMIT = 1
CELERY_BROKER_CONNECTION_MAX_RETRIES = 100

settings_remote.py:

CELERY_BROKER_URL = os.environ['CLOUDAMQP_URL']

__ init.py __ :

from .celery_tasks import app as celery_app
__all__ = ['celery_app']

celery_tasks.py:

import os
from celery import Celery
from celery.schedules import crontab
from datetime import datetime, timedelta
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'terradiem.settings')
from django.conf import settings
app = Celery('terradiem')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)

app.conf.CELERYBEAT_SCHEDULE = \
    {
        'updateavcontribrating_task':
            {
                'task': 'gautocomplete.tasks.updateavplacecontribratingregular',
                'schedule': crontab(0, 0, day_of_month='2'),

            },
     }

gautocomplete/tasks.py :

@app.task(bind=True)
def updateavplacecontribratingregular(self):
    Etc...

Error message :

Sep 29 16:15:25 terradiem app/beat.1:  -------------- celery@6e5f2660-eba2-4db3-9aba-5ac2b9547b70 v4.3.0 (rhubarb) 
Sep 29 16:15:25 terradiem app/beat.1: ---- **** -----  
Sep 29 16:15:25 terradiem app/beat.1: --- * ***  * -- Linux-4.4.0-1054-aws-x86_64-with-debian-buster-sid 2019-09-29 16:15:24 
Sep 29 16:15:25 terradiem app/beat.1: -- * - **** ---  
Sep 29 16:15:25 terradiem app/beat.1: - ** ---------- [config] 
Sep 29 16:15:25 terradiem app/beat.1: - ** ---------- .> app:         terradiem:0x7f56212a8550 
Sep 29 16:15:25 terradiem app/beat.1: - ** ---------- .> transport:   amqp://dfmngfek:**@salamander.rmq.cloudamqp.com:5672/dfmngfek 
Sep 29 16:15:25 terradiem app/beat.1: - ** ---------- .> results:     disabled:// 
Sep 29 16:15:25 terradiem app/beat.1: - *** --- * --- .> concurrency: 8 (prefork) 
Sep 29 16:15:25 terradiem app/beat.1: -- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker) 
Sep 29 16:15:25 terradiem app/beat.1: --- ***** -----  
Sep 29 16:15:25 terradiem app/beat.1:  -------------- [queues] 
Sep 29 16:15:25 terradiem app/beat.1:                 .> celery           exchange=celery(direct) key=celery 
Sep 29 16:15:25 terradiem app/beat.1:                  
Sep 29 16:15:25 terradiem app/beat.1:  
Sep 29 16:15:25 terradiem app/beat.1: [tasks] 
Sep 29 16:15:25 terradiem app/beat.1:   . gautocomplete.tasks.updateavplacecontribratingregular 
Sep 29 16:15:25 terradiem app/beat.1:  
Sep 29 16:15:26 terradiem app/web.1: DEBUG 2019-09-29 16:15:25,821 base 12 139757909414400 Configuring Raven for host: https://sentry.io 
Sep 29 16:15:26 terradiem app/beat.1: [2019-09-29 16:15:26,075: INFO/Beat] beat: Starting... 
Sep 29 16:15:29 terradiem app/beat.1: [2019-09-29 16:15:29,041: ERROR/MainProcess] consumer: Cannot connect to amqp://dfmngfek:**@salamander.rmq.cloudamqp.com:5672/dfmngfek: [Errno 104] Connection reset by peer. 
Sep 29 16:15:29 terradiem app/beat.1: Trying again in 2.00 seconds... 

Any help would be more than useful!


Solution

  • The usage limit of CloudAMPQ was exceeded. I opted for a larger plan and the error did not appear anymore.