Force reconnect on server shutdown
This commit is contained in:
parent
532f55cb86
commit
935c5b309a
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const $ = require("jquery");
|
const $ = require("jquery");
|
||||||
const io = require("socket.io-client");
|
const io = require("socket.io-client");
|
||||||
|
const utils = require("./utils");
|
||||||
const path = window.location.pathname + "socket.io/";
|
const path = window.location.pathname + "socket.io/";
|
||||||
const status = $("#loading-page-message, #connection-error");
|
const status = $("#loading-page-message, #connection-error");
|
||||||
|
|
||||||
@ -43,6 +44,12 @@ function handleDisconnect(data) {
|
|||||||
status.text(`Waiting to reconnect… (${message})`).addClass("shown");
|
status.text(`Waiting to reconnect… (${message})`).addClass("shown");
|
||||||
$(".show-more-button, #input").prop("disabled", true);
|
$(".show-more-button, #input").prop("disabled", true);
|
||||||
$("#submit").hide();
|
$("#submit").hide();
|
||||||
|
|
||||||
|
// If the server shuts down, socket.io skips reconnection
|
||||||
|
// and we have to manually call connect to start the process
|
||||||
|
if (socket.io.skipReconnect) {
|
||||||
|
utils.requestIdleCallback(() => socket.connect(), 2000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = socket;
|
module.exports = socket;
|
||||||
|
Loading…
Reference in New Issue
Block a user