summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2024-04-06 00:44:20 +0300
committerEd Tanous <ed@tanous.net>2024-04-21 02:37:02 +0300
commit515f46565a93f71ecd8b683198797b1690d3b5f8 (patch)
tree0e1b9eff6809c458082dbec8eaa2781c5eb3544a
parentd1ef18e6f9ed1527b66cec07eba6acaf9a95819c (diff)
downloadwebui-vue-515f46565a93f71ecd8b683198797b1690d3b5f8.tar.xz
Remove /subscribe websocket handler
Having this code is causing crashes for implementations that don't have dbus-rest enabled in bmcweb, which is deprecated. This commit is intended to start a discussion around this issue, and propose simply removing it. 33a8c5369e0253a93dba2e70647bda1c7697b73b (checked in July 2020) points this crash out, and adds a way to disable the feature. While we could just make VUE_APP_SUBSCRIBE_SOCKET_DISABLED the default, this seems ill advised, given the dbus-rest options deprecated status. Change-Id: I6244f5e2ce895199d5d47cfca9eef36584e8f524 Signed-off-by: Ed Tanous <ed@tanous.net>
-rw-r--r--.env.intel1
-rw-r--r--src/store/index.js2
-rw-r--r--src/store/plugins/WebSocketPlugin.js60
3 files changed, 0 insertions, 63 deletions
diff --git a/.env.intel b/.env.intel
index 382e7fb6..79d07f05 100644
--- a/.env.intel
+++ b/.env.intel
@@ -2,7 +2,6 @@ NODE_ENV=production
VUE_APP_ENV_NAME="intel"
VUE_APP_COMPANY_NAME="intel"
VUE_APP_GUI_NAME="BMC System Management"
-VUE_APP_SUBSCRIBE_SOCKET_DISABLED="true"
VUE_APP_SWITCH_TO_BACKUP_IMAGE_DISABLED="true"
VUE_APP_MODIFY_SSH_POLICY_DISABLED="true"
VUE_APP_VIRTUAL_MEDIA_LIST_ENABLED="true"
diff --git a/src/store/index.js b/src/store/index.js
index 8b1ed078..453e0f64 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -31,7 +31,6 @@ import FactoryResetStore from './modules/Operations/FactoryResetStore';
import SnmpAlertsStore from './modules/Settings/SnmpAlertsStore';
import KeyClearStore from './modules/Operations/KeyClearStore';
-import WebSocketPlugin from './plugins/WebSocketPlugin';
import DateTimeStore from './modules/Settings/DateTimeStore';
import VirtualMediaStore from './modules/Operations/VirtualMediaStore';
@@ -74,5 +73,4 @@ export default new Vuex.Store({
factoryReset: FactoryResetStore,
keyClear: KeyClearStore,
},
- plugins: [WebSocketPlugin],
});
diff --git a/src/store/plugins/WebSocketPlugin.js b/src/store/plugins/WebSocketPlugin.js
deleted file mode 100644
index cbdc9329..00000000
--- a/src/store/plugins/WebSocketPlugin.js
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * WebSocketPlugin will allow us to get new data from the server
- * without having to poll for changes on the frontend.
- *
- * This plugin is subscribed to host state property and logging
- * changes, indicated in the app header Health and Power status.
- *
- * https://github.com/openbmc/docs/blob/b41aff0fabe137cdb0cfff584b5fe4a41c0c8e77/rest-api.md#event-subscription-protocol
- */
-const WebSocketPlugin = (store) => {
- let ws;
- const data = {
- paths: ['/xyz/openbmc_project/state/host0', '/xyz/openbmc_project/logging'],
- interfaces: [
- 'xyz.openbmc_project.State.Host',
- 'xyz.openbmc_project.Logging.Entry',
- ],
- };
-
- const initWebSocket = () => {
- const socketDisabled =
- process.env.VUE_APP_SUBSCRIBE_SOCKET_DISABLED === 'true' ? true : false;
- if (socketDisabled) return;
- const token = store.getters['authentication/token'];
- ws = new WebSocket(`wss://${window.location.host}/subscribe`, [token]);
- ws.onopen = () => {
- ws.send(JSON.stringify(data));
- };
- ws.onerror = (event) => {
- console.error(event);
- };
- ws.onmessage = (event) => {
- const data = JSON.parse(event.data);
- const eventInterface = data.interface;
- const path = data.path;
-
- if (eventInterface === 'xyz.openbmc_project.State.Host') {
- const { properties: { CurrentHostState } = {} } = data;
- if (CurrentHostState) {
- store.commit('global/setServerStatus', CurrentHostState);
- }
- } else if (path === '/xyz/openbmc_project/logging') {
- store.dispatch('eventLog/getEventLogData');
- }
- };
- };
-
- store.subscribe(({ type }) => {
- if (type === 'authentication/authSuccess') {
- initWebSocket();
- }
- if (type === 'authentication/logout') {
- if (ws) ws.close();
- }
- });
-
- if (store.getters['authentication/isLoggedIn']) initWebSocket();
-};
-
-export default WebSocketPlugin;