Skip to content

Commit

Permalink
feat(client): Send ws message periodically
Browse files Browse the repository at this point in the history
Fix #5
  • Loading branch information
DJDuque committed Aug 24, 2024
1 parent 3d65fcd commit b46f15a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions assets/run_info/run_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ const ws = new WebSocket(protocol + "//" + loc.host + loc.pathname + "/../ws");

ws.onopen = function () {
document.getElementById("downloadButton").disabled = false;

// If server is running behind a reverse proxy, the WebSocket connection may
// be terminated after a period of inactivity. Keep the connection alive by
// sending a ping message every 30 seconds.
const pingInterval = 30 * 1000;
setInterval(function () {
ws.send(JSON.stringify({ service: "Heartbeat" }));
}, pingInterval);
};

// The WebSocket connection is closed when the page is unloaded. In this case,
Expand Down

0 comments on commit b46f15a

Please sign in to comment.