简体   繁体   English

找不到“ / lobby /” django-channels路由错误

[英]Not Found “/lobby/” django-channels routing error

routing.py routing.py

from channels import include, route
from chat import consumers
from . import game_consumers

channel_routing = [
    #game routing
    route('websocket.connect', game_consumers.ws_connect_lobby, path=r"^/lobby/$"),
    route('websocket.receive', game_consumers.ws_receive_lobby, path=r"^/lobby/$"),
    route('websocket.disconnect', game_consumers.ws_disconnect_lobby, path=r"^/lobby/$"),

app.js app.js

Websocket = {
    lobby_socket: null,
    setup_ws_lobby : function(){
        Websocket.lobby_socket = new ReconnectingWebSocket(Websocket.ws_scheme + '://' + window.location.host + '/lobby/');
        Websocket.lobby_socket.onmessage = function(message) {
            //nothing yet
        };
    },
}
Websocket.setup_ws_lobby();

The url is 127.0.0.1:8000/game . 网址是127.0.0.1:8000/game Websocket.setup_ws_lobby() is executed on page load. Websocket.setup_ws_lobby()在页面加载时执行。 I don't see what I'm doing wrong. 我看不到我在做什么错。 I get the error Not Found: /lobby/ in my python manage.py runserver console when I load the page. 加载页面时,在python manage.py runserver控制台中收到错误Not Found: /lobby/ My routes are clearly set and my js setup seems to route to those routes. 我的路由已明确设置,我的js设置似乎已路由到这些路由。 Can anyone help? 有人可以帮忙吗? Thanks in advance. 提前致谢。

The code is valid; 该代码有效; it was a version issue. 这是一个版本问题。 Upgraded to 1.1.8 and it worked 升级到1.1.8并正常工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM