Отчаянно пытаясь понять, что здесь происходит
WebSocket HANDSHAKING /ws/lobby/ [127.0.0.1:65205]
WebSocket CONNECT /ws/lobby/ [127.0.0.1:65205]
Exception inside application: [Errno 8] nodename nor servname provided, or not known
File "/anaconda3/lib/python3.7/site-packages/channels/sessions.py", line 183, in __call__
return await self.inner(receive, self.send)
File "/anaconda3/lib/python3.7/site-packages/channels/middleware.py", line 41, in coroutine_call
await inner_instance(receive, send)
File "/anaconda3/lib/python3.7/site-packages/channels/consumer.py", line 59, in __call__
[receive, self.channel_receive], self.dispatch
File "/anaconda3/lib/python3.7/site-packages/channels/utils.py", line 58, in await_many_dispatch
await task
File "/anaconda3/lib/python3.7/site-packages/channels/utils.py", line 50, in await_many_dispatch
result = task.result()
File "/anaconda3/lib/python3.7/site-packages/channels_redis/core.py", line 429, in receive
real_channel
File "/anaconda3/lib/python3.7/site-packages/channels_redis/core.py", line 484, in receive_single
index, channel_key, timeout=self.brpop_timeout
File "/anaconda3/lib/python3.7/site-packages/channels_redis/core.py", line 324, in _brpop_with_clean
async with self.connection(index) as connection:
File "/anaconda3/lib/python3.7/site-packages/channels_redis/core.py", line 820, in __aenter__
self.conn = await self.pool.pop()
File "/anaconda3/lib/python3.7/site-packages/channels_redis/core.py", line 70, in pop
conns.append(await aioredis.create_redis(**self.host, loop=loop))
File "/anaconda3/lib/python3.7/site-packages/aioredis/commands/__init__.py", line 175, in create_redis
loop=loop)
File "/anaconda3/lib/python3.7/site-packages/aioredis/connection.py", line 113, in create_connection
timeout)
File "/anaconda3/lib/python3.7/asyncio/tasks.py", line 388, in wait_for
return await fut
File "/anaconda3/lib/python3.7/site-packages/aioredis/stream.py", line 24, in open_connection
lambda: protocol, host, port, **kwds)
File "/anaconda3/lib/python3.7/asyncio/base_events.py", line 899, in create_connection
type=socket.SOCK_STREAM, proto=proto, flags=flags, loop=self)
File "/anaconda3/lib/python3.7/asyncio/base_events.py", line 1268, in _ensure_resolved
proto=proto, flags=flags)
File "/anaconda3/lib/python3.7/asyncio/base_events.py", line 778, in getaddrinfo
None, getaddr_func, host, port, family, type, proto, flags)
File "/anaconda3/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/anaconda3/lib/python3.7/socket.py", line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
[Errno 8] nodename nor servname provided, or not known
WebSocket DISCONNECT /ws/lobby/ [127.0.0.1:65205]
Я не совсем понимаю, что происходит в этом сообщении об ошибке, но я кое-что заметил с каналом redis. Вот мой слой канала в setting.py
CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {
#"hosts": [os.environ.get('REDISTOGO_URL',('redis', 6379))],
"hosts": [('redis', 6379)],
},
},
}
Вот мой потребительский класс
class LobbyConsumer(JsonWebsocketConsumer):
def connect(self):
self.accept()
def disconnect(self, close_code):
pass
def receive(self, text_data):
text_data_json = json.loads(text_data)
message = text_data_json['message']
self.send(text_data=json.dumps({
'message': message
}))
И вот этот
var lobby_sock = 'ws://' + window.location.host + "/ws/lobby/"
ReactDOM.render(<LobbyBase current_user={current_user} socket={lobby_sock}/>, document.getElementById('lobby_component'))
render() {
return (
<div className="row">
<Websocket ref="socket" url={this.props.socket}
onMessage={this.handleData.bind(this)} reconnect={true}
/>
<span>Lobby Components will go here....</span>
</div>
)
}
Мне интересно, что вызывает эту проблему? Websocket рукопожатия, подключиться, а затем просто отключиться из-за этой ошибки? Что это за ошибка? Что, вероятно, вызывает проблему? Я думаю, что это весь мой код, связанный с websockt. Любая помощь будет оценена!