Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throws AuthenticationError despite providing password in settings. #193

Open
shrutimansinghka opened this issue Jun 30, 2020 · 1 comment

Comments

@shrutimansinghka
Copy link

shrutimansinghka commented Jun 30, 2020

CACHES = {
    "default": {
        "BACKEND": "redis_cache.RedisCache",
        "LOCATION": [
           env('CACHE_MASTER_URL'),
            env('CACHE_SLAVE_URL'),
        ],
        "OPTIONS": {
            'DB': 1,
            "PASSWORD": env('CACHE_PASSWORD'),
            'MASTER_CACHE': env('CACHE_MASTER_URL')
        }
    }
}

Stack Trace:

----> 1 cache.set("test-1", "test-val", 3060)

~/Documents/workspace/michan_api/app-code/michan/lib/python3.6/site-packages/redis_cache/backends/base.py in wrapped(self, key, *args, **kwargs)
     28             key = self.make_key(key, version=version)
     29             client = self.get_client(key, write=write)
---> 30             return method(self, client, key, *args, **kwargs)
     31
     32         return wrapped

~/Documents/workspace/michan_api/app-code/michan/lib/python3.6/site-packages/redis_cache/backends/base.py in set(self, client, key, value, timeout)
    279         """
    280         timeout = self.get_timeout(timeout)
--> 281         result = self._set(client, key, self.prep_value(value), timeout, _add_only=False)
    282         return result
    283

~/Documents/workspace/michan_api/app-code/michan/lib/python3.6/site-packages/redis_cache/backends/base.py in _set(self, client, key, value, timeout, _add_only)
    272         elif timeout == 0:
    273             return client.expire(key, 0)
--> 274         return client.set(key, value, nx=_add_only, ex=timeout)
    275
    276     @get_client(write=True)

~/Documents/workspace/michan_api/app-code/michan/lib/python3.6/site-packages/redis/client.py in set(self, name, value, ex, px, nx, xx)
   1764         if xx:
   1765             pieces.append('XX')
-> 1766         return self.execute_command('SET', *pieces)
   1767
   1768     def __setitem__(self, name, value):

~/Documents/workspace/michan_api/app-code/michan/lib/python3.6/site-packages/redis/client.py in execute_command(self, *args, **options)
    873         pool = self.connection_pool
    874         command_name = args[0]
--> 875         conn = self.connection or pool.get_connection(command_name, **options)
    876         try:
    877             conn.send_command(*args)

~/Documents/workspace/michan_api/app-code/michan/lib/python3.6/site-packages/redis/connection.py in get_connection(self, command_name, *keys, **options)
   1183             try:
   1184                 # ensure this connection is connected to Redis
-> 1185                 connection.connect()
   1186                 # connections that the pool provides should be ready to send
   1187                 # a command. if not, the connection was either returned to the

~/Documents/workspace/michan_api/app-code/michan/lib/python3.6/site-packages/redis/connection.py in connect(self)
    559         self._sock = sock
    560         try:
--> 561             self.on_connect()
    562         except RedisError:
    563             # clean up after any error in on_connect

~/Documents/workspace/michan_api/app-code/michan/lib/python3.6/site-packages/redis/connection.py in on_connect(self)
    656         if self.db:
    657             self.send_command('SELECT', self.db)
--> 658             if nativestr(self.read_response()) != 'OK':
    659                 raise ConnectionError('Invalid Database')
    660

~/Documents/workspace/michan_api/app-code/michan/lib/python3.6/site-packages/redis/connection.py in read_response(self)
    732         "Read the response from a previously sent command"
    733         try:
--> 734             response = self._parser.read_response()
    735         except socket.timeout:
    736             self.disconnect()

~/Documents/workspace/michan_api/app-code/michan/lib/python3.6/site-packages/redis/connection.py in read_response(self)
    331             # is notified
    332             if isinstance(error, ConnectionError):
--> 333                 raise error
    334             # otherwise, we're dealing with a ResponseError that might belong
    335             # inside a pipeline response. the connection's read_response()

AuthenticationError: Authentication required.
@bnmounir
Copy link

I had the same issue. The response was coming from the Redis server, running version 6.2.5.
The error is due to the username not being passed in from django-redis-cache to redis-py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants