routes.js
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/$"),
client.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 localhost:8000/chat
. The function Websocket.setup_ws_lobby()
is triggered on page load. Despite setting up the routes correctly and ensuring the javascript setup is also correct, I keep getting the error message Not Found: /lobby/
in my terminal when running python manage.py runserver
after loading the page. Any help would be appreciated. Thank you.