Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shell Access disconnects quickly #2269

Closed
barche opened this issue Sep 5, 2022 · 5 comments · Fixed by #3135 · May be fixed by wtripp180901/ondemand#1
Closed

Shell Access disconnects quickly #2269

barche opened this issue Sep 5, 2022 · 5 comments · Fixed by #3135 · May be fixed by wtripp180901/ondemand#1
Milestone

Comments

@barche
Copy link

barche commented Sep 5, 2022

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

@osc-bot osc-bot added this to the Backlog milestone Sep 5, 2022
@johrstrom
Copy link
Contributor

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.

@barche
Copy link
Author

barche commented Oct 24, 2023

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);

@johrstrom
Copy link
Contributor

Thanks! pull requests (and/or git diff's) welcome! I'll try to put this in 3.1 - the next release.

@barche
Copy link
Author

barche commented Oct 24, 2023

@wtripp180901 do you want to make a PR for ondemand with this? I can do it too, but it's your code :)

@wtripp180901
Copy link
Contributor

Yeah sure I'll put one in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants