Websocket using Django Channels

回眸只為那壹抹淺笑 提交于 2019-12-04 17:02:17

You should also have a consumer for the websocket.connect and accept the connection, only after accepting the connection the protocol server will complete the websocket handshake

channel_routing = {
    "websocket.connect": consumers.ws_connect,
}

consumers.py

def ws_connect(message):
    message.reply_channel.send({
        'accept': True
})

see http://channels.readthedocs.io/en/latest/releases/1.0.0.html#websocket-accept-reject-flow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!