I encountered an issue with the WebSocket connection to 'ws://127.0.0.1:8000/room/ws/tech' failing. I am currently exploring how to develop a real-time Django application using channels and referring to this informative tutorial.
During my attempt to establish a websocket, the console displayed the following error :
WebSocket connection to 'ws://127.0.0.1:8000/ws/tech/' failed
This is the code snippet where I am trying to create the websocket -
console.log("roomname: "+roomName);
const chatSocket = new WebSocket(
'ws://'
+ window.location.host
+ '/ws/'
+ roomName
+ '/'
);
I can confirm that the URL is being constructed correctly. Even when manually entering 'ws://127.0.0.1:8000/room/ws/tech' in a browser console, it still throws the same error.