0

I'm trying to connect sentinels, but every time we got the same error

Exception: Could not connect to any sentinel

CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "channels_redis.core.RedisChannelLayer",
        "CONFIG": {
               "hosts": [
                   { "sentinels": [("redis-cluster.local.svc.cluster.local", 26379, )]
                   , "master_name": "mymaster"}
                   ]}
        },
    }

I can't figure out where to put the password key and db key. And do I need to put in the url the sentinels url's ? or service is enough? note: when trying to connect redis/sentinels without channels we do not have any issue at all

shaharnakash
  • 675
  • 3
  • 11
  • 39

1 Answers1

1

From the channels_redis readme:

hosts

The server(s) to connect to, as either URIs, (host, port) tuples, or dicts conforming to create_connection. Defaults to ['localhost', 6379]. Pass multiple hosts to enable sharding, but note that changing the host list will lose some sharded data.

Sentinel connections require dicts conforming to create_sentinel with an additional master_name key specifying the Sentinel master set. Plain Redis and Sentinel connections can be mixed and matched if sharding.

(emphasis mine)

From what I read it doesn't seem possible to use URIs for sentinel connections, so if you want to set the db and password keys you need to add the relevant keys in the hosts list item:

CHANNEL_LAYERS = {
  "default": {
    "BACKEND": "channels_redis.core.RedisChannelLayer",
    "CONFIG": {
      "hosts": [
        {
          "sentinels": [
            ("redis-cluster.local.svc.cluster.local", 26379, )
          ],
          "master_name": "mymaster",
          "db": 0,
          "password": "your_password"
        }
      ]
    }
  }
}