diff --git a/install/data/defaults.json b/install/data/defaults.json index 1f08ca4ad8..556cf055c7 100644 --- a/install/data/defaults.json +++ b/install/data/defaults.json @@ -150,5 +150,7 @@ "useCompression": 0, "updateUrlWithPostIndex": 1, "composer:showHelpTab": 1, - "composer:allowPluginHelp": 1 + "composer:allowPluginHelp": 1, + "maxReconnectionAttempts": 5, + "reconnectionDelay": 1500 } \ No newline at end of file diff --git a/public/language/en-GB/error.json b/public/language/en-GB/error.json index 63b5ebdee5..9b1fbcc789 100644 --- a/public/language/en-GB/error.json +++ b/public/language/en-GB/error.json @@ -208,6 +208,7 @@ "already-blocked": "This user is already blocked", "already-unblocked": "This user is already unblocked", "no-connection": "There seems to be a problem with your internet connection", + "socket-reconnect-failed": "Reconnect failed, please try again later", "plugin-not-whitelisted": "Unable to install plugin – only plugins whitelisted by the NodeBB Package Manager can be installed via the ACP" } diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index a5a6cae576..08a83597e1 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -409,6 +409,7 @@ ajaxify = window.ajaxify || {}; require(['translator', 'benchpress'], function (translator, Benchpress) { translator.translate('[[error:no-connection]]'); + translator.translate('[[error:socket-reconnect-failed]]'); Benchpress.registerLoader(ajaxify.loadTemplate); Benchpress.setGlobal('config', config); }); diff --git a/public/src/sockets.js b/public/src/sockets.js index 722f6785af..18f5204897 100644 --- a/public/src/sockets.js +++ b/public/src/sockets.js @@ -45,8 +45,10 @@ socket = window.socket; socket.on('disconnect', onDisconnect); socket.io.on('reconnect_failed', function () { - // Wait ten times the reconnection delay and then start over - setTimeout(socket.connect.bind(socket), parseInt(config.reconnectionDelay, 10) * 10); + $('#reconnect-alert').removeClass('alert-warning') + .addClass('alert-danger') + .find('p') + .translateText('[[error:socket-reconnect-failed]]'); }); socket.on('checkSession', function (uid) { diff --git a/src/controllers/api.js b/src/controllers/api.js index 80b13f961d..ac6313152f 100644 --- a/src/controllers/api.js +++ b/src/controllers/api.js @@ -49,8 +49,8 @@ apiController.loadConfig = async function (req) { socketioTransports, socketioOrigins, websocketAddress, - maxReconnectionAttempts: meta.config.maxReconnectionAttempts || 5, - reconnectionDelay: meta.config.reconnectionDelay || 1500, + maxReconnectionAttempts: meta.config.maxReconnectionAttempts, + reconnectionDelay: meta.config.reconnectionDelay, topicsPerPage: meta.config.topicsPerPage || 20, postsPerPage: meta.config.postsPerPage || 20, maximumFileSize: meta.config.maximumFileSize,