【问题标题】:django channels: WebSocket is closed before the connection is establisheddjango 频道:在建立连接之前关闭 WebSocket
【发布时间】:2017-09-21 12:49:37
【问题描述】:

我是 django 频道的新手。我读了this tutorial 来创建一个实时聊天应用程序,但是我有这个错误

在 Chrome 中:

WebSocket connection to 'ws://127.0.0.1:8000/chat/stream/' failed: WebSocket is closed before the connection is established.

在 Firefox 中:

Firefox can't establish a connection to the server at ws://127.0.0.1:8001/chat/stream/.

The connection to ws://127.0.0.1:8001/chat/stream/ was interrupted while the page was loading.

请帮助我。非常感谢。

【问题讨论】:

  • 请给我们看代码。最好从消费者和路由开始。

标签: django websocket django-channels


【解决方案1】:

您可能在代码中错过了这一点:

message.reply_channel.send({"accept": True})

ws_connect

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-14
    • 1970-01-01
    • 2020-10-21
    • 1970-01-01
    • 1970-01-01
    • 2018-08-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多