How to recover from Django Channels connection limit?

33 views
Skip to first unread message

hype...@gmail.com

unread,
Oct 29, 2020, 8:57:18 PM10/29/20
to Django users

I'm running a server on heroku where I have intermittent channel layer communications between instances of asyncConsumers. Running heroku locally, I have no problem with redis channel connection since I can have as many of them as I want, but once I upload my server to heroku, it gives me a 20 redis connection limit. If I use more than that my server errors out, so I try to lower the expiry time so inactive redis connections would close. BUT, if a redis connection expires and I try to use the channel name with self.channel_layer.send(), I'll get the error below, how do I recover from this error without having to have external calls to create another asyncConsumer instance?


ERROR Exception inside application: Reader at end of file File "/app/.heroku/python/lib/python3.6/site-packages/channels/consumer.py", line 59, in __call__ [receive, self.channel_receive], self.dispatch File "/app/.heroku/python/lib/python3.6/site-packages/channels/utils.py", line 51, in await_many_dispatch await dispatch(result) File "/app/.heroku/python/lib/python3.6/site-packages/channels/consumer.py", line 73, in dispatch await handler(message) File "./myapp/webhook.py", line 133, in http_request await self.channel_layer.send(userDB.backEndChannelName,{"type": "device.query"}) File "/app/.heroku/python/lib/python3.6/site-packages/channels_redis/core.py", line 296, in send if await connection.llen(channel_key) >= self.get_capacity(channel): File "/app/.heroku/python/lib/python3.6/site-packages/aioredis/commands/list.py", line 70, in llen return self.execute(b'LLEN', key) File "/app/.heroku/python/lib/python3.6/site-packages/aioredis/commands/__init__.py", line 51, in execute return self._pool_or_conn.execute(command, *args, **kwargs) File "/app/.heroku/python/lib/python3.6/site-packages/aioredis/connection.py", line 322, in execute raise ConnectionClosedError(msg) Reader at end of file

Reply all
Reply to author
Forward
0 new messages