My websocket onerror callback does not fire when I disconnect the browser which is on a seperate computer from the websocket server on another computer by turning off the wifi connection and sending a message. The message just doesn't send but no error is fired. Here is my code snippet below.
const logged_in_user_id = 2;
WEBSOCKET_URL = `wss://${window.location.host}/ws/${logged_in_user_id}/`;
const realTimeDataSocket = new WebSocket(WEBSOCKET_URL)
realTimeDataSocket.addEventListener("open", function() {
console.log("Websocket is opened.");
realTimeDataSocket.send(JSON.stringify({
"event": "online",
"message": "This user is online"
}))
});
realTimeDataSocket.addEventListener("close", function() {
console.log("Websocket was closed.");
});
realTimeDataSocket.addEventListener("error", function() {
console.log("Websocket was closed due to an error.");
});