Error: The webpage you were looking for in the lobby cannot be found due to a django-channels routing

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.

Answer №1

The code was deemed valid after resolving a version compatibility issue by upgrading to 1.1.8

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Building upon the preceding inquiry, a ReferenceError has occurred due to the object being undefined

After researching online, I came across a similar question marked as a duplicate that brought me to this link: How do I return the response from an asynchronous call?. Even though I couldn't find a solution in that thread, it seems like I may need to ...

AngularJS: Utilizing ellipsis for text overflow and optimization

As a beginner in angularJS, I might have made some mistakes... Can anyone guide me on how to properly implement this plugin: https://github.com/BeSite/jQuery.dotdotdot on my table? Currently, the performance of my edit form and table is very slow. What c ...

Django's asynchronous celery feature is malfunctioning

Having trouble creating an asynchronous task using celery, I have encountered some challenges. One of my tasks involves sending emails: @shared_task() def send_email_example(email_id): ... I invoke this task using the delay() method: class SomeModel ...

Issue with executing Django Q object

Attempting to create an OR query using Django filters has proven to be more difficult than anticipated. Despite multiple attempts, I have yet to achieve the desired outcome. What could be the issue? from django.db.models import Q from models import Proces ...

Confirming Deletion with a Jquery and Ajax Popup Box

I am seeking assistance with a specific task. Although my function is functioning well with ajax, I am in need of an "ok" or "cancel" delete confirmation box before submitting the ajax request to remove an item from the database. Here is the code I am cu ...

What is the method for prompting a save as dialog in the browser in order to save JSON data stored in memory?

As the title suggests, I am looking for a way to store JSON data in memory. I want this action to be triggered by an onclick event on a DOM object. The goal is to save the data on the user's computer as if they were downloading a file. Saving it as t ...

Tips for implementing X-XSS-Protection: 1; mode=block in HTML

I'm struggling with where to place this piece of code in my existing code. Should it be added to the header section? <head> <meta content="text/html; charset=UTF-8; X-Content-Type-Options=nosniff" http-equiv="Content-Type" /> <title> ...

What exactly does form.getHeaders(); mean?

Attempting to streamline the upload process, I have come up with the following code: var http = require('http'); var request = http.request({ method: 'post', host: 'https://www.ws-ti.4bank.com', path: '/img/create ...

A Beginner's Guide to Duplicating Bootstrap Containers in Jade

I am working with JSON data that is being transmitted from an Express and Mongoose Stack to be displayed on the user interface created in Jade. I am wondering which Jade Construct I should use to loop through a Bootstrap Container of col-md-4 using Jade s ...

Discovering the value of a key within a JSON object by utilizing a String with JQuery

Given a JSON object, the challenge is to extract values based on user input. The input format will be similar to "data.location.type" or "data.location.items[1].address.street". Is it achievable using JQuery? { "data": { "location": { ...

What steps can we take to create a personalized PDF editor incorporating our unique edit functionalities using Vue.js?

Is it possible to create a PDF editor similar to MS Word using vuejs? How can I implement custom logic in the PDF editor with vuejs? For example, the features should include: Conditional replacement of text Adding tags to text within the PDF Changing the ...

The default export of Nuxt, referred to as 'mod', could not be located

Using Nuxt with Typescript, I have created a custom component as shown below: <template> <div class="field"> <label class="label" v-if="typeof label !== 'undefined'">{{ label }}</label> <div class=" ...

Tips for displaying a modal to a user only once

I've developed a Flask application that enables multiple users to register and log in. To achieve this, I have incorporated sessions into my code. When new users land on the initial page, they are greeted with a modal introducing them to the platform. ...

Troubleshooting Static File Serving Issue in Django 1.11 on PythonAnywhere

I am currently in the process of deploying a Django 1.11 application to a PythonAnywhere environment. In the settings file, I have added 'django.contrib.staticfiles' to the INSTALLED_APPS and configured the static settings as follows: STATIC_UR ...

Clicking on a single checkbox causes the entire input to become deactivated due to the way the system is

I'm encountering a puzzling issue that has me feeling like I know the solution, yet I don't. I set "State" to [checked]. The problem arises when, upon turning it into a map and clicking just one checkbox, the entire selection is clicked. To addre ...

Warning: The DataTables alert has been triggered for table ID DimStatus. It is indicating that an unknown parameter, 'Code', has been requested for row 0 and column 0 during the initialization

https://i.stack.imgur.com/yEpSp.pngI am encountering an error while attempting to display my data in a datatable. The structure of my table is as follows: [Table("DimStatus", Schema = "dmg")] public class PolicyState { [Key] ...

Customize the Focus event for a third-party page being displayed in an iframe

When an external page loads in an iframe, it automatically gains focus causing the page to scroll to that specific iframe. Is there a method to prevent this automatic focus override? ...

What is the best way to transition a connected component from a class-based to a functional component in TypeScript?

I'm in the process of switching from a class-based component to a functional component. This is a connected component that uses mapState. Here is my initial setup: import { connect } from 'react-redux' import { fetchArticles } from '. ...

Tips for transferring a Spring MVC controller variable to JavaScript

I am currently working on retrieving a variable for a JavaScript function from an object that is sent to the view by the controller. The object I am dealing with is called Bpmsn. https://i.sstatic.net/FxlAo.png Through the controller, I have injected th ...

The fadeIn() and fadeOut() functions solely conceal

I attempted to incorporate jQuery's fadeIn and fadeOut functions, but found that they only work for the specified duration, causing the elements to appear/disappear abruptly without smoothly transitioning the opacity. Here is the code snippet I used: ...