django / channels_redis

Redis channel layer backend for Django Channels
BSD 3-Clause "New" or "Revised" License
602 stars 197 forks source link

Allow passing extra connection kwargs with host address #337

Closed marcinowski closed 1 year ago

marcinowski commented 2 years ago

This should fix some of the issues with #331 by allowing to pass extra connection arguments with the host configuration. The specific case that this helps me with is passing the ssl kwargs into the connection as advised by Heroku redis docs

nasir733 commented 2 years ago

@carltongibson what do you think about this pull request?

carltongibson commented 2 years ago

@nasir733 I haven't had a chance to review it yes, otherwise I'd have commented. (@mentioning me doesn't help. I feel we've discussed this before... 😅)

If you want to give it a run, verify it works (or not) for you and comment along those lines, then that would be a useful thing to do. (If it does work you're then able to use this branch whilst waiting for a release.)

bbrowning918 commented 2 years ago

Again with test hangs, I helped fight these not too long ago. I think with #342 also fixing pubsub's connection the two can be combined into one.

jackkinsella commented 2 years ago

The approach in my PR seemed to just replace this issue with another: TypeError: Connection.__init__() got an unexpected keyword argument 'ssl' - however this might be because I am also usingrq`

File "/app/.heroku/python/lib/python3.11/site-packages/channels/routing.py", line 116, in __call__
app[web.1]: return await application(
File "/app/.heroku/python/lib/python3.11/site-packages/channels/consumer.py", line 94, in app
return await consumer(scope, receive, send)
File "/app/.heroku/python/lib/python3.11/site-packages/channels/consumer.py", line 58, in __call__
await await_many_dispatch(
File "/app/.heroku/python/lib/python3.11/site-packages/channels/utils.py", line 57, in await_many_dispatch
await task
File "/app/.heroku/src/channels-redis/channels_redis/core.py", line 368, in receive
message_channel, message = await self.receive_single(
File "/app/.heroku/src/channels-redis/channels_redis/core.py", line 423, in receive_single
content = await self._brpop_with_clean(
File "/app/.heroku/src/channels-redis/channels_redis/core.py", line 259, in _brpop_with_clean
await connection.eval(cleanup_script, 0, channel, backup_queue)
File "/app/.heroku/python/lib/python3.11/site-packages/redis/asyncio/client.py", line 484, in execute_command
conn = self.connection or await pool.get_connection(command_name, **options)
File "/app/.heroku/python/lib/python3.11/site-packages/redis/asyncio/connection.py", line 1520, in get_connection
connection = self.make_connection()
File "/app/.heroku/python/lib/python3.11/site-packages/redis/asyncio/connection.py", line 1560, in make_connection
return self.connection_class(**self.connection_kwargs)
File "/app/.heroku/python/lib/python3.11/site-packages/redis/asyncio/connection.py", line 1088, in __init__
super().__init__(**kwargs)
TypeError: Connection.__init__() got an unexpected keyword argument 'ssl'

Perhaps a parallel with https://github.com/rq/rq/pull/1383

carltongibson commented 1 year ago

Resolved in #352. Thanks.