我在heroku上部署django频道时遇到了一个问题,同时使用了redischannellayer。
我得到一个 UnicodeError: encoding with 'idna' codec failed (UnicodeError: label empty or too long)
在连接过程中(下面是完整的回溯)。
这似乎是一个与主机地址中的一个标签过长有关的问题,如本期python所示。
我从我的消费者那里打印了一些信息,还 Package 了python的 socket.getaddrinfo
显示主机和连接信息的模块。
这个相关的帖子在连接shopify时遇到了同样的问题,而不是redis示例,他们通过在请求头中放置凭证来解决这个问题。但我无法控制 channels_redis
或者 asyncio
.
有什么线索吗?
django渠道消费者的属性:
.组 []
.channel\u层 RedisChannelLayer(hosts=[{'address': ('h:alongkeycomprisingof65charsintotalx@ec2-18-202-152-61.eu-west-1.compute.amazonaws.com', '9759')}])
.channel\u名称 specific.OSfTzyqY!pdvgHnaCxWiv
.房间名称 8e3d3083-8bb1-4d85-89d3-4496d9b9e946
.房间\组\名称 twined_8e3d3083-8bb1-4d85-89d3-4496d9b9e946
####完全回溯:
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.6/site-packages/channels/sessions.py", line 183, in __call__
return await self.inner(receive, self.send)
File "/app/.heroku/python/lib/python3.6/site-packages/channels/middleware.py", line 41, in coroutine_call
await inner_instance(receive, send)
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 "/app/.heroku/python/lib/python3.6/site-packages/channels/generic/websocket.py", line 175, in websocket_connect
await self.connect()
File "/app/backend/pink/consumers.py", line 24, in connect
await self.channel_layer.group_add(self.room_group_name, self.channel_name)
File "/app/.heroku/python/lib/python3.6/site-packages/channels_redis/core.py", line 589, in group_add
async with self.connection(self.consistent_hash(group)) as connection:
File "/app/.heroku/python/lib/python3.6/site-packages/channels_redis/core.py", line 835, in __aenter__
self.conn = await self.pool.pop()
File "/app/.heroku/python/lib/python3.6/site-packages/channels_redis/core.py", line 73, in pop
conns.append(await aioredis.create_redis(**self.host, loop=loop))
File "/app/.heroku/python/lib/python3.6/site-packages/aioredis/commands/__init__.py", line 175, in create_redis
loop=loop)
File "/app/.heroku/python/lib/python3.6/site-packages/aioredis/connection.py", line 113, in create_connection
timeout)
File "/app/.heroku/python/lib/python3.6/asyncio/tasks.py", line 339, in wait_for
return (yield from fut)
File "/app/.heroku/python/lib/python3.6/site-packages/aioredis/stream.py", line 24, in open_connection
lambda: protocol, host, port,**kwds)
File "/app/.heroku/python/lib/python3.6/asyncio/base_events.py", line 750, in create_connection
infos = f1.result()
File "/app/.heroku/python/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args,**self.kwargs)
File "./backend/amy/asgi.py", line 69, in mygetaddrinfo
for res in socket._socket.getaddrinfo(host, port, family, type, proto, flags):
UnicodeError: encoding with 'idna' codec failed (UnicodeError: label empty or too long)
1条答案
按热度按时间xmd2e60i1#
我可以通过建立
RedisChannelLayer
用论据口述create_connection
(如本文所述,不是提供很长的主机名。通过手动解析heroku提供给我的redis\uurl变量中的密码,并重建
host
如果没有uri,我可以将该密码作为单独的字段添加到create_connection
dict,将主机字符串长度保持在64个字符以下。我用我的时间做这个
settings.py
文件,现在看起来像: