我正在尝试使用heroku-redis运行频道2.0.2(Django 2.0.2)@ Heroku的多媒体示例。 但是我需要NOAUTH身份验证(顺便说一下:我能够在本地运行):
2018-02-20T02:16:34.648943+00:00 app[web.1]: 10.45.77.75:32339 - - [20/Feb/2018:02:16:34] "WSCONNECTING /chat/stream/" - -
2018-02-20T02:16:34.649549+00:00 app[web.1]: 2018-02-20 02:16:34,649 DEBUG Upgraded connection ['10.45.77.75', 32339] to WebSocket
2018-02-20T02:16:34.650407+00:00 app[web.1]: 2018-02-20 02:16:34,650 DEBUG Creating tcp connection to ('ec2-34-238-60-32.compute-1.amazonaws.com', 28169)
2018-02-20T02:16:34.659050+00:00 app[web.1]: 2018-02-20 02:16:34,658 DEBUG WebSocket ['10.45.77.75', 32339] open and established
2018-02-20T02:16:34.659217+00:00 app[web.1]: 10.45.77.75:32339 - - [20/Feb/2018:02:16:34] "WSCONNECT /chat/stream/" - -
2018-02-20T02:16:34.659974+00:00 app[web.1]: 2018-02-20 02:16:34,659 DEBUG WebSocket ['10.45.77.75', 32339] accepted by application
2018-02-20T02:16:34.666248+00:00 app[web.1]: 2018-02-20 02:16:34,666 DEBUG Closed 0 connection(s)
2018-02-20T02:16:35.085802+00:00 app[web.1]: 2018-02-20 02:16:35,085 ERROR Exception inside application: NOAUTH Authentication required.
2018-02-20T02:16:35.085814+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/channels/consumer.py", line 54, in __call__
2018-02-20T02:16:35.085816+00:00 app[web.1]: await await_many_dispatch([receive, self.channel_receive], self.dispatch)
2018-02-20T02:16:35.085818+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/channels/utils.py", line 47, in await_many_dispatch
2018-02-20T02:16:35.085820+00:00 app[web.1]: result = task.result()
2018-02-20T02:16:35.085822+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/channels_redis/core.py", line 160, in receive
2018-02-20T02:16:35.085824+00:00 app[web.1]: return await self.receive_buffer_lpop(channel)
2018-02-20T02:16:35.085826+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/channels_redis/core.py", line 222, in receive_buffer_lpop
2018-02-20T02:16:35.085828+00:00 app[web.1]: task.result()
2018-02-20T02:16:35.085829+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/channels_redis/core.py", line 173, in receive_loop
2018-02-20T02:16:35.085831+00:00 app[web.1]: real_channel, message = await self.receive_single(channel)
2018-02-20T02:16:35.085833+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/channels_redis/core.py", line 189, in receive_single
2018-02-20T02:16:35.085835+00:00 app[web.1]: pool = await self.connection(index)
2018-02-20T02:16:35.085836+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/channels_redis/core.py", line 386, in connection
2018-02-20T02:16:35.085838+00:00 app[web.1]: self.pools[index] = await aioredis.create_redis_pool(**self.hosts[index])
2018-02-20T02:16:35.085840+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/aioredis/commands/__init__.py", line 197, in create_redis_pool
2018-02-20T02:16:35.085842+00:00 app[web.1]: loop=loop)
2018-02-20T02:16:35.085843+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/aioredis/pool.py", line 56, in create_pool
2018-02-20T02:16:35.085845+00:00 app[web.1]: await pool._fill_free(override_min=False)
2018-02-20T02:16:35.085847+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/aioredis/pool.py", line 391, in _fill_free
2018-02-20T02:16:35.085848+00:00 app[web.1]: await conn.execute('ping')
2018-02-20T02:16:35.085903+00:00 app[web.1]: NOAUTH Authentication required.
2018-02-20T02:16:35.258329+00:00 app[web.1]: 2018-02-20 02:16:35,258 DEBUG WebSocket closed for ['10.45.77.75', 32339]
2018-02-20T02:16:35.258485+00:00 app[web.1]: 10.45.77.75:32339 - - [20/Feb/2018:02:16:35] "WSDISCONNECT /chat/stream/" - -
我的settings.py有以下内容(我已将密码发送到日志,并且与heroku的网站(凭据)通知的密码相匹配)
redis_url = urlparse(os.environ.get('REDIS_URL'))
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"LOCATION": "{0}:{1}".format(redis_url.hostname, redis_url.port),
"OPTIONS": {
"PASSWORD": redis_url.password,
"DB": 0,
},
"CONFIG": {"hosts": [(redis_url.hostname, redis_url.port)]},
}
}