From bd584e468c1f0ef6cc11756e5506c2d7c455262d Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 11 Nov 2022 08:45:55 -0700 Subject: [PATCH] Check if websocket is connected as part of pushAvailable() check --- api/js/jsapi/egw_json.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/js/jsapi/egw_json.js b/api/js/jsapi/egw_json.js index 11818bdaab..00baf6d0a8 100644 --- a/api/js/jsapi/egw_json.js +++ b/api/js/jsapi/egw_json.js @@ -98,6 +98,7 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) const check_interval = 30000; // 30 sec const max_ping_response_time = 1000; let reconnect_time = min_reconnect_time; + let websocket = null; /** * Open websocket to push server (and keeps it open) @@ -128,7 +129,7 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) }.bind(this), max_ping_response_time); }.bind(this); - this.websocket = new WebSocket(url); + websocket = this.websocket = new WebSocket(url); this.websocket.onopen = (e) => { check_timer = window.setTimeout(check, check_interval); @@ -446,7 +447,7 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) */ pushAvailable: function() { - return reconnect_time === min_reconnect_time; + return websocket !== null && websocket.readyState == websocket.OPEN && reconnect_time === min_reconnect_time; }, /** The constructor of the egw_json_request class.