From b1cadbf018f0db4e02ad5319167b6ff0df344422 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Sun, 12 Apr 2020 20:03:24 +0530 Subject: [PATCH] fix: Limit retries --- socketio.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/socketio.js b/socketio.js index 1f5d530c04..95e8414914 100644 --- a/socketio.js +++ b/socketio.js @@ -73,6 +73,7 @@ io.on('connection', function (socket) { }); // end frappe.chat + let retries = 0; let join_chat_room = () => { request.get(get_url(socket, '/api/method/frappe.realtime.get_user_info')) .type('form') @@ -85,11 +86,12 @@ io.on('connection', function (socket) { socket.join(get_site_room(socket)); }) .catch(e => { - if (e.code === 'ECONNREFUSED') { + if (e.code === 'ECONNREFUSED' && retries < 5) { // retry after 1s + retries += 1; return setTimeout(join_chat_room, 1000); } - log(e.code); + log(`Unable to join chat room. ${e}`); }); };