From 5210ea593f0e01f6714ee94ef51bee4af2432cf3 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Mon, 14 Nov 2022 14:03:25 +0530 Subject: [PATCH] fix(socketio): Re-try thrice before trying to reconnect Set reconnectionAttempts to 3. If the server doesn't want to connect with the respective client (invalid origin, no cookie or sid transmitted) or is gone down, socketio client would retry connections indefinitely. This change limits retrying connection to just thrice every second. --- frappe/public/js/frappe/socketio_client.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frappe/public/js/frappe/socketio_client.js b/frappe/public/js/frappe/socketio_client.js index 9e290ede0b..d091d3f5e7 100644 --- a/frappe/public/js/frappe/socketio_client.js +++ b/frappe/public/js/frappe/socketio_client.js @@ -17,14 +17,17 @@ frappe.socketio = { frappe.socketio.socket = io.connect(frappe.socketio.get_host(port), { secure: true, withCredentials: true, + reconnectionAttempts: 3, }); } else if (window.location.protocol == "http:") { frappe.socketio.socket = io.connect(frappe.socketio.get_host(port), { withCredentials: true, + reconnectionAttempts: 3, }); } else if (window.location.protocol == "file:") { frappe.socketio.socket = io.connect(window.localStorage.server, { withCredentials: true, + reconnectionAttempts: 3, }); }