AMBARI-25928: Continuous increase of websocket connections in Ambari web UI (#3783)

diff --git a/ambari-web/app/utils/stomp_client.js b/ambari-web/app/utils/stomp_client.js
index 8d4b95b..cb0af27 100644
--- a/ambari-web/app/utils/stomp_client.js
+++ b/ambari-web/app/utils/stomp_client.js
@@ -59,6 +59,11 @@
   isConnected: false,
 
   /**
+   * @type {number | null}
+   */
+  timerId: null,
+
+  /**
    * @type {boolean}
    */
   isWebSocketSupported: true,
@@ -157,9 +162,13 @@
   },
 
   reconnect: function(useSockJS) {
+    if (this.timerId !== null) {
+      clearTimeout(this.timerId);
+    }
     const subscriptions = Object.assign({}, this.get('subscriptions'));
-    setTimeout(() => {
+    this.timerId = setTimeout(() => {
       console.debug('Reconnecting to WebSocket...');
+      this.disconnect();
       this.connect(useSockJS).done(() => {
         this.set('subscriptions', {});
         for (let i in subscriptions) {
@@ -173,7 +182,10 @@
   },
 
   disconnect: function () {
-    this.get('client').disconnect();
+    var client = this.get('client');
+    if (client.ws.readyState === client.ws.OPEN) {
+      client.disconnect();
+    }
   },
 
   /**