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

django-redis TypeError: __init__() got an unexpected keyword argument 'ssl' #635

Open
yosmelvin opened this issue Dec 8, 2022 · 0 comments
Labels

Comments

@yosmelvin
Copy link

yosmelvin commented Dec 8, 2022

Describe the bug
this bug happend when I want to make connection to redis cluster with use TLS

To Reproduce
Steps to reproduce the behavior:

  1. here is my config on settings.py:
'redis-cluster-tls': {
    'BACKEND': 'django_redis.cache.RedisCache',
    'LOCATION': 'rediss://:[email protected]',
    'OPTIONS': {
        'REDIS_CLIENT_CLASS': 'rediscluster.RedisCluster',
        'CONNECTION_POOL_CLASS': 'rediscluster.connection.ClusterConnectionPool',
        'CONNECTION_POOL_KWARGS': {
            'skip_full_coverage_check': True,
            'ssl': True,
        },
        "SOCKET_CONNECT_TIMEOUT": 20
        "SOCKET_TIMEOUT": 20
    },
    "KEY_PREFIX": 'dev'
}

Expected behavior
it can get value and set to redis cluster with use TLS (Connection Type: OSS Cluster)

Stack trace

traceback: Traceback (most recent call last):
  File "/Users/macbook2015/.local/share/virtualenvs/xxxxx-CWlIwagZ/lib/python3.9/site-packages/rediscluster/connection.py", line 364, in get_connection_by_node
    connection = self._available_connections.get(node["name"], []).pop()
IndexError: pop from empty list

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/macbook2015/.local/share/virtualenvs/'-CWlIwagZ/lib/python3.9/site-packages/rediscluster/client.py", line 615, in _execute_command
    connection = self.connection_pool.get_connection_by_node(node)
  File "/Users/macbook2015/.local/share/virtualenvs/xxxxx-CWlIwagZ/lib/python3.9/site-packages/rediscluster/connection.py", line 366, in get_connection_by_node
    connection = self.make_connection(node)
  File "/Users/macbook2015/.local/share/virtualenvs/xxxxx-CWlIwagZ/lib/python3.9/site-packages/rediscluster/connection.py", line 273, in make_connection
    connection = self.connection_class(host=node["host"], port=node["port"], **self.connection_kwargs)
  File "/Users/macbook2015/.local/share/virtualenvs/xxxxx-CWlIwagZ/lib/python3.9/site-packages/redis/connection.py", line 828, in __init__
    super(SSLConnection, self).__init__(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'ssl'

Environment (please complete the following information):
Python==3.9
Django==4.1.4
django-redis==5.2.0
redis==3.5.3
redis-py-cluster==2.1.3

additional context:
If I try some changes on redis-py package acctually its fixed the problem but can you guys help me to fix in django-redis instead of fix on redis-py

before:

class SSLConnection(Connection):

    def __init__(self, ssl_keyfile=None, ssl_certfile=None,
                 ssl_cert_reqs='required', ssl_ca_certs=None,
                 ssl_check_hostname=False, **kwargs):
        if not ssl_available:
            raise RedisError("Python wasn't built with SSL support")
            
        super(SSLConnection, self).__init__(**kwargs)

        self.keyfile = ssl_keyfile
        self.certfile = ssl_certfile

after:

class SSLConnection(Connection):

    def __init__(self, ssl_keyfile=None, ssl_certfile=None,
                 ssl_cert_reqs='required', ssl_ca_certs=None,
                 ssl_check_hostname=False, **kwargs):
        if not ssl_available:
            raise RedisError("Python wasn't built with SSL support")
        
        if 'ssl' in kwargs:
            del kwargs['ssl']
        
        super(SSLConnection, self).__init__(**kwargs)

        self.keyfile = ssl_keyfile
        self.certfile = ssl_certfile
@yosmelvin yosmelvin added the bug label Dec 8, 2022
@yosmelvin yosmelvin changed the title TypeError: __init__() got an unexpected keyword argument 'ssl' django-redis TypeError: __init__() got an unexpected keyword argument 'ssl' Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant