This is an automated email from the ASF dual-hosted git repository.
vjasani pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new 1fb531c31e AMBARI-25928: Continuous increase of websocket connections
in Ambari web UI (#3783)
1fb531c31e is described below
commit 1fb531c31e86688d5d3a696d4ad6d07921d99aa1
Author: zrain <[email protected]>
AuthorDate: Sat Apr 27 10:17:02 2024 +0800
AMBARI-25928: Continuous increase of websocket connections in Ambari web UI
(#3783)
---
ambari-web/app/utils/stomp_client.js | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/ambari-web/app/utils/stomp_client.js
b/ambari-web/app/utils/stomp_client.js
index 8d4b95b5fe..cb0af27770 100644
--- a/ambari-web/app/utils/stomp_client.js
+++ b/ambari-web/app/utils/stomp_client.js
@@ -58,6 +58,11 @@ module.exports = Em.Object.extend({
*/
isConnected: false,
+ /**
+ * @type {number | null}
+ */
+ timerId: null,
+
/**
* @type {boolean}
*/
@@ -157,9 +162,13 @@ module.exports = Em.Object.extend({
},
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 @@ module.exports = Em.Object.extend({
},
disconnect: function () {
- this.get('client').disconnect();
+ var client = this.get('client');
+ if (client.ws.readyState === client.ws.OPEN) {
+ client.disconnect();
+ }
},
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]