ondemand
ondemand copied to clipboard
Shell Access disconnects quickly
Hi, I am running ondemand-2.1.20220901-127532.4b5f020.nightly.el9.x86_64
and the shell app (under the "Clusters" tab) disconnects often after less than a minute of inactivity. I'm not sure why, since as far as I can tell there are no errors in the logs. I didn't change anything from the default config for this application.
┆Issue is synchronized with this Asana task by Unito
Hi, thanks for the ticket. I'm not sure what the timeouts are, but I don't believe we implement ping/pong to keep it alive either.
Which is to say, thanks for the ticket.
I can confirm the patch from the linked issue above solves this for me, diff for OOD 3.0.3 shell app.js
:
--- app.js_orig 2023-10-24 17:03:42.376562196 +0200
+++ app.js 2023-10-24 17:03:49.445438516 +0200
@@ -96,6 +96,12 @@
return [hostname, directory];
}
+function noop() {}
+
+function heartbeat() {
+ this.isAlive = true;
+}
+
function custom_server_origin(default_value = null){
var custom_origin = null;
@@ -188,6 +194,9 @@
if (msg.resize) term.resize(parseInt(msg.resize.cols), parseInt(msg.resize.rows));
});
+ ws.isAlive = true;
+ ws.on('pong', heartbeat);
+
ws.on('close', function () {
term.end();
console.log('Closed terminal: ' + term.pid);
@@ -195,6 +204,14 @@
}
});
+const interval = setInterval(function ping() {
+ wss.clients.forEach(function each(ws) {
+ if (ws.isAlive === false) return ws.terminate();
+ ws.isAlive = false;
+ ws.ping(noop);
+ });
+}, 30000);
+
server.on('upgrade', function upgrade(request, socket, head) {
wss.handleUpgrade(request, socket, head, function done(ws) {
wss.emit('connection', ws, request);
Thanks! pull requests (and/or git diff's) welcome! I'll try to put this in 3.1 - the next release.
@wtripp180901 do you want to make a PR for ondemand with this? I can do it too, but it's your code :)
Yeah sure I'll put one in