我有一个简短的问题,如何在AWS Elasticbeanstalk上设置Django-channels v2?下面是更长、不那么吸引人的问题。
谢谢您提前的帮助!我正在尝试使用Django Channels 2.02设置elasticbeanstalk实例。我遵循了这个https://hackernoon.com/setting-up-django-channels-on-aws-elastic-beanstalk-716fd5a49c4a教程。该教程是为Channels 1编写的。
Elasticbeanstalk实例使用应用程序负载均衡器创建。Redis 4.0实例正在运行0.0.0.0:6379,通过netstat确认。在redis实例上自定义TCP,端口范围:6379,源:0.0.0.0/0。
在.ebekstension中的alb_listener.config文件:
option_settings: aws:elbv2:listener:80:
DefaultProcess: http
ListenerEnabled: 'true'
Protocol: HTTP aws:elasticbeanstalk:environment:process:http:
Port: '8000'
Protocol: HTTP
Daphne服务器使用命令"Daphne .asgi:application"启动。监听TCP地址0.0.0.0:8000。它返回:
2018-03-12 08:59:30,778 ERROR Exception inside application: [Errno -2] Name or service not known
File "/opt/python/run/venv/local/lib/python3.6/site-packages/channels/consumer.py", line 54, in __call__
await await_many_dispatch([receive, self.channel_receive], self.dispatch)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/channels/utils.py", line 47, in await_many_dispatch
result = task.result()
File "/opt/python/run/venv/local/lib/python3.6/site-packages/channels_redis/core.py", line 167, in receive
task.result()
File "/opt/python/run/venv/local/lib/python3.6/site-packages/channels_redis/core.py", line 187, in receive_loop
real_channel, message = await self.receive_single(general_channel)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/channels_redis/core.py", line 224, in receive_single
async with self.connection(index) as connection:
File "/opt/python/run/venv/local/lib/python3.6/site-packages/channels_redis/core.py", line 403, in __aenter__
self.conn = await aioredis.create_redis(**self.kwargs)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/aioredis/commands/__init__.py", line 174, in create_redis
loop=loop)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/aioredis/connection.py", line 107, in create_connection
timeout, loop=loop)
File "/usr/lib64/python3.6/asyncio/tasks.py", line 339, in wait_for
return (yield from fut)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/aioredis/stream.py", line 19, in open_connection
lambda: protocol, host, port, **kwds)
File "/usr/lib64/python3.6/asyncio/base_events.py", line 733, in create_connection
infos = f1.result()
File "/usr/lib64/python3.6/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/lib64/python3.6/socket.py", line 743, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
[Errno -2] Name or service not known
浏览器控制台中没有Websocket错误。
它在我的本地运行服务器上可以工作。问题出在哪里?请帮我编写一个配置脚本,这样我就不需要手动启动Daphne了吗?