Python使用channel过程中,channels_redis在setting.py的各种配置(包括有密码连接的配置)

setting.py的配置

 

无密码的配置:

1、

CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "channels_redis.core.RedisChannelLayer",
        "CONFIG": {
            "hosts": [("localhost", 6379)],
        },
    },
}

2、

CHANNEL_LAYERS = {
    'default': {
    'BACKEND': 'channels_redis.core.RedisChannelLayer',
    'CONFIG': {"hosts": ["redis://127.0.0.1:6379/8"],},
    },
}

3、

CHANNEL_LAYERS = {
    'default': {
    'BACKEND': 'channels_redis.core.RedisChannelLayer',
    'CONFIG': {"hosts": [('127.0.0.1', 6379)],},},
}

有密码的配置:

 

如红框所示 

CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "channels_redis.core.RedisChannelLayer",
        "CONFIG": {
            "hosts": ["redis://:password@127.0.0.1:6379/0"],
            "symmetric_encryption_keys": [SECRET_KEY],
        },
    },
}

版权声明:本文为qq_38680405原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。