feat: Make ENABLE_WEBSOCKET_SUPPORT disable polling entirely to allow multiple replicas without sticky sessions.

See https://socket.io/docs/v4/using-multiple-nodes/ for details why this was done.

Also create a redis key to track which replica is running the cleanup job
This commit is contained in:
Jason Kidd
2024-12-06 13:03:01 -08:00
parent a38934bd23
commit 8f51681801
4 changed files with 87 additions and 32 deletions

View File

@@ -38,13 +38,15 @@
let loaded = false;
const BREAKPOINT = 768;
const setupSocket = () => {
const setupSocket = (disableWebSocketPolling) => {
console.log('Disabled websocket polling', disableWebSocketPolling);
const _socket = io(`${WEBUI_BASE_URL}` || undefined, {
reconnection: true,
reconnectionDelay: 1000,
reconnectionDelayMax: 5000,
randomizationFactor: 0.5,
path: '/ws/socket.io',
transports: disableWebSocketPolling ? ['websocket'] : ['polling', 'websocket'],
auth: { token: localStorage.token }
});
@@ -125,8 +127,9 @@
await config.set(backendConfig);
await WEBUI_NAME.set(backendConfig.name);
const disableWebSocketPolling = backendConfig.features.disable_websocket_polling === true;
if ($config) {
setupSocket();
setupSocket(disableWebSocketPolling);
if (localStorage.token) {
// Get Session User Info