Sidi Zawi
Sidi Zawi

Reputation: 345

Django Celery Redis

I have this error A rediss:// URL must have parameter ssl_cert_reqs and this must be set to CERT_REQUIRED, CERT_OPTIONAL, or CERT_NONE

settings

CELERY_BROKER_URL = os.environ.get('REDIS_URL', "redis://localhost:6379")
CELERY_RESULT_BACKEND = os.environ.get('REDIS_URL', "redis://localhost:6379")
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'

celery.py

from __future__ import absolute_import, unicode_literals
from celery import Celery
import os, ssl

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproj.settings')

app = Celery(
'myproj',
broker_use_ssl = {
    'ssl_cert_reqs': ssl.CERT_NONE
})

app.config_from_object('django.conf:settings', namespace="CELERY")

app.autodiscover_tasks()

I changed the value of ssl_cert_reqs to different value 'none', 'cert_required', ..., but nothing, always the same error when I use rediss:// instead of redis://.

Upvotes: 5

Views: 3986

Answers (2)

emmaakachukwu
emmaakachukwu

Reputation: 625

Adding a faster solution that worked for me - I updated my REDIS_URL value and appended ?ssl_cert_reqs=CERT_NONE. CERT_NONE can be replaced with CERT_OPTIONAL or CERT_NONE depending on the availability of the SSL cert

If REDIS_URL is an environment value in your app, then you probably don't need to change your code; just edit the value of the variable in your server or .env file as the case may be

Upvotes: 0

dtmkeng
dtmkeng

Reputation: 176

i never used option broker_use_ssl, can you try delete this option and try again

app = Celery('myproj')

or update

 Celery('myproj',
     broker_use_ssl = {
        'ssl_cert_reqs': ssl.CERT_NONE
     },
     redis_backend_use_ssl = {
        'ssl_cert_reqs': ssl.CERT_NONE
     }
)

Upvotes: 14

Related Questions