channels icon indicating copy to clipboard operation
channels copied to clipboard

How to set password for connection with redis?

Open onegreyonewhite opened this issue 10 years ago • 12 comments

Is there any such option in the channel? As this password is specified in the config file?

Now I use this config:

CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "asgi_redis.RedisChannelLayer",
        "ROUTING": "widget.routing.channel_routing",
        "CONFIG": {
            "hosts": [("127.0.0.1", 6379)],
        },
    },
}

onegreyonewhite avatar May 20 '16 02:05 onegreyonewhite

No, the backend does not support Redis passwords; I'll add it to the list of features to get in there, though encryption support is probably higher-priority as Redis passwords are really not secure.

andrewgodwin avatar May 20 '16 03:05 andrewgodwin

It seems to me you do not know all the possibilities of your product. I used here is just these settings:

CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "asgi_redis.RedisChannelLayer",
        "ROUTING": "widget.routing.channel_routing",
        "CONFIG": {
            "hosts": [("redis://:[email protected]:6379/0")],
        },
    },
}

and it worked. Close this issue now.

P.S.: Add this info into your documentation. It may be useful for somebody.

onegreyonewhite avatar May 20 '16 04:05 onegreyonewhite

Ah, fair enough, I didn't realise the redis backend string did that.

andrewgodwin avatar May 20 '16 04:05 andrewgodwin

Does this issue fixed now??? I can't find the way to set redis password from document.

russelltao avatar Mar 01 '17 10:03 russelltao

Just follow the example above and set it in the connection string.

andrewgodwin avatar Mar 01 '17 17:03 andrewgodwin

This commit resolves the issue: Add redis's password from config to txredisapi. (#41)

Nuurek avatar May 08 '17 17:05 Nuurek

Thank you so much @onegreyonewhite !

aparnabushan-zz avatar Oct 04 '20 09:10 aparnabushan-zz

Hey thanks for it save me alot alot of headache. Thanks.🙏🙏🙏

devs001 avatar Mar 15 '21 12:03 devs001

Thank you very much, I've been trying to solve this issue for a couple of days with no luck.

malmukhtar avatar Apr 16 '21 09:04 malmukhtar

Thanks a lot, it worked @onegreyonewhite. But can anyone help me with the reason, why it works?

vishwas-chill avatar Aug 03 '21 17:08 vishwas-chill

Thanks a lot, it worked @onegreyonewhite. But can anyone help me with the reason, why it works?

This works because ConnectionPool supports url scheme.

onegreyonewhite avatar Aug 03 '21 23:08 onegreyonewhite

Notice that python ignores parentheses when wrapping single element, so

"hosts": [("redis://:[email protected]:6379/0")],

euqals

"hosts": ["redis://:[email protected]:6379/0"],

however, leving a comma at the end makes it a tuple, and acceable tuple format should be (host, port), so code below will cause error

"hosts": [("redis://:[email protected]:6379/0", )],

TonyYanOnFire avatar Aug 10 '22 08:08 TonyYanOnFire