diff --git a/console/templates/console-xterm.html b/console/templates/console-xterm.html index 7a93f754..050bf664 100644 --- a/console/templates/console-xterm.html +++ b/console/templates/console-xterm.html @@ -14,6 +14,7 @@ {% block navbarstatus %} {% trans "Connecting" %} {% endblock %} diff --git a/static/js/console_serial.js b/static/js/console_serial.js index 4a0e34bc..89042cdf 100644 --- a/static/js/console_serial.js +++ b/static/js/console_serial.js @@ -58,13 +58,14 @@ socket.on('connect', () => { socket.on('taken_over', (data) => { takenBy = data.by; }); -socket.on('disconnect', () => { +socket.on('disconnect', (reason) => { if (takenBy) { const text = status.dataset.takenOver.replace('%(name)s', takenBy); term.write('\r\n[' + text + ']\r\n'); showStatus(text, 'danger'); } else { - showStatus(status.dataset.disconnected, 'danger'); + // the user's Disconnect, or the server's end (the terminal says why) or a lost connection + showStatus(reason === 'io client disconnect' ? status.dataset.disconnected : status.dataset.lost, 'danger'); } }); // the server says why: serial console off, an expired link, the console open elsewhere diff --git a/static/js/console_vnc.js b/static/js/console_vnc.js index 9655eb80..3c1f8897 100644 --- a/static/js/console_vnc.js +++ b/static/js/console_vnc.js @@ -23,6 +23,7 @@ const rfb = new RFB(document.getElementById('screen'), url, let connected = false; let closed = false; +let disconnecting = false; // the user's Disconnect, not a lost connection let refusal = null; function showStatus(text, color) { @@ -47,7 +48,8 @@ rfb.addEventListener('disconnect', (e) => { } else if (!connected) { showStatus(status.dataset.failed, 'danger'); } else { - showStatus(e.detail.clean ? status.dataset.disconnected : status.dataset.lost, 'danger'); + // noVNC calls a server's close clean too: the VM's stop, a migration, a restarted proxy + showStatus(disconnecting ? status.dataset.disconnected : status.dataset.lost, 'danger'); } connectionButton.textContent = connectionButton.dataset.reconnect; credentialsDialog.hide(); @@ -58,6 +60,7 @@ connectionButton.addEventListener('click', () => { if (closed) { window.location.reload(); } else { + disconnecting = true; rfb.disconnect(); } });