如何从django通道连接限制恢复?

zlhcx6iw  于 2021-06-09  发布在  Redis
关注(0)|答案(0)|浏览(291)

我在heroku上运行一个服务器,在那里异步用户示例之间有间歇性的通道层通信。在本地运行heroku,我对redis通道连接没有问题,因为我可以拥有任意数量的redis通道,但是一旦我将服务器上传到heroku,它就给了我20个redis连接的限制。如果我使用了超过这个数,我的服务器就会出错,所以我会尽量降低到期时间,这样非活动的redis连接就会关闭。但是,如果redis连接过期,并且我尝试将通道名称与self.channel\u layer.send()一起使用,我将得到下面的错误,如何从该错误中恢复,而不必通过外部调用来创建另一个asyncconsumer示例?

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

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题