mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-10 07:55:46 +01:00
fixed issue where socket.io would no longer reconnect perpetually, new behaviour waits 10x the reconnect delay, and then starts over. Also upped the reconnection delay default to 1.5s.
This commit is contained in:
@@ -17,12 +17,12 @@ app.cacheBuster = null;
|
||||
function socketIOConnect() {
|
||||
var ioParams = {
|
||||
reconnectionAttempts: config.maxReconnectionAttempts,
|
||||
reconnectionDelay : config.reconnectionDelay,
|
||||
reconnectionDelay: config.reconnectionDelay,
|
||||
transports: config.socketioTransports,
|
||||
path: config.relative_path + '/socket.io'
|
||||
};
|
||||
|
||||
socket = io.connect(config.websocketAddress, ioParams);
|
||||
socket = io(config.websocketAddress, ioParams);
|
||||
reconnecting = false;
|
||||
|
||||
socket.on('event:connect', function () {
|
||||
@@ -41,11 +41,6 @@ app.cacheBuster = null;
|
||||
});
|
||||
|
||||
socket.on('reconnecting', function (attempt) {
|
||||
if(attempt === parseInt(config.maxReconnectionAttempts, 10)) {
|
||||
socket.io.attempts = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
reconnecting = true;
|
||||
var reconnectEl = $('#reconnect');
|
||||
|
||||
@@ -74,6 +69,11 @@ app.cacheBuster = null;
|
||||
socket.on('event:alert', function(data) {
|
||||
app.alert(data);
|
||||
});
|
||||
|
||||
socket.on('reconnect_failed', function() {
|
||||
// Wait ten times the reconnection delay and then start over
|
||||
setTimeout(socket.connect.bind(socket), parseInt(config.reconnectionDelay, 10) * 10);
|
||||
});
|
||||
}
|
||||
|
||||
function onSocketConnect(data) {
|
||||
|
||||
Reference in New Issue
Block a user