如何设置Celery以将SSL与Azure Redis实例进行对话 [英] How to setup Celery to talk ssl to Azure Redis Instance

查看:67
本文介绍了如何设置Celery以将SSL与Azure Redis实例进行对话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对"如何要在microsoft azure上的django项目中配置celery-redis?",我可以使用以下Python代码通过 non-ssl端口6379 将Celery配置为使用Azure Redis缓存:

Using the great answer to "How to configure celery-redis in django project on microsoft azure?", I can configure Celery to use Azure Redis Cache using the non-ssl port, 6379, using the following Python code:

from celery import Celery
# This one works
url = 'redis://:<access key>@<my server>.redis.cache.windows.net:6379/0'
# I want to use a url that specifies ssl like one of the following:
# url = 'redis://:<my key>=@<my server>.redis.cache.windows.net:6380/0'
# url = 'redis://:<my key>@<my server>.redis.cache.windows.net:6380/0?ssl=True'
app = Celery('tasks', broker=url)

@app.task
def add(x, y):
    return x + y

但是,我想让celery使用ssl并使用ssl在端口3380上进行通讯到Azure Redis缓存.如果将端口更改为6380,则在运行以下命令几分钟后,会出现从套接字读取错误"消息:

However, I would like to have celery use ssl and communicate on port 3380 using ssl to the Azure Redis Cache. If I change the port to 6380, I get an "Error while reading from socket" after a few minutes of waiting after running the following command:

celery-任务处理程序--loglevel = INFO -Q"celery" -Ofair

有人知道如何在Celery或Azure端进行配置,以便我可以使用 ssl 在Azure Redis缓存的默认 3380 端口上进行celery通信.?

Does anyone know how to configure this, on the Celery or Azure side, so that I can have celery communicate on the default 3380 port on Azure Redis Cache using ssl?

我正在使用最新版本的Celery(4.0.2)

I am using the latest version of Celery (4.0.2)

请注意,当使用端口3380和使用Python的redis库的ssl直接从 Linux客户端(在Azure上)直接连接时,以下代码可以正常工作:

Note that code like the following works with no problem when connecting directly from a Linux client (on Azure) using port 3380 and ssl using Python's redis library:

import redis
redis.StrictRedis(host='<my host>.redis.cache.windows.net', port=6380, db=0, password='<my key>', ssl=True)

推荐答案

对于代理,您应该能够设置

For the broker, you should be able to set the broker_use_ssl configuration option.

对于后端,选项 redis_backend_use_ssl 在4.1.0版本中可用.

For the backend, the option redis_backend_use_ssl was made available in the 4.1.0 release.

尚无法通过URL启用SSL: https://github.com/celery/celery/issues/2833

The ability to enable SSL via the URL isn't available yet: https://github.com/celery/celery/issues/2833

此外,请注意, Windows的官方支持已被删除4.0 .但是,您可以按照 https://github.com上的说明进行操作/celery/celery/issues/4082

Also, note that official support for Windows was dropped in 4.0. However, you might be able to get it working by following the instructions at https://github.com/celery/celery/issues/4082

这篇关于如何设置Celery以将SSL与Azure Redis实例进行对话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆