diff --git a/src/node/handler/PadMessageHandler.ts b/src/node/handler/PadMessageHandler.ts index 47fee8481..1d7a4dd21 100644 --- a/src/node/handler/PadMessageHandler.ts +++ b/src/node/handler/PadMessageHandler.ts @@ -1251,6 +1251,7 @@ const _getRoomSockets = (padID: string) => { // it does here, but synchronously to avoid a race condition. This code will have to change when // we update to socket.io v3. const room = ns.adapter.rooms?.get(padID); + if (!room) return []; return Array.from(room) diff --git a/src/node/hooks/express/socketio.ts b/src/node/hooks/express/socketio.ts index c2f5dd225..896d0779f 100644 --- a/src/node/hooks/express/socketio.ts +++ b/src/node/hooks/express/socketio.ts @@ -94,6 +94,7 @@ exports.expressCreateServer = (hookName:string, args:ArgsExpressType, cb:Functio io.use(exports.socketSessionMiddleware(args)); + // Temporary workaround so all clients go through middleware and handle connection io.of('/pluginfw/installer').use(exports.socketSessionMiddleware(args)) io.of('/settings').use(exports.socketSessionMiddleware(args)) diff --git a/src/static/js/socketio.js b/src/static/js/socketio.js index 83fb45c55..3bc7dba58 100644 --- a/src/static/js/socketio.js +++ b/src/static/js/socketio.js @@ -21,20 +21,19 @@ const connect = (etherpadBaseUrl, namespace = '/', options = {}) => { const namespaceUrl = new URL(namespace, new URL('/', baseUrl)); let socketOptions = { - ...options, path: socketioUrl.pathname, upgrade: true, transports: ["websocket"] } - socketOptions = Object.assign(socketOptions, options); + socketOptions = Object.assign(options, socketOptions); const socket = io(namespaceUrl.href, socketOptions); socket.on('connect_error', (error) => { if (socket.io.engine.transports.indexOf('polling') === -1) { - console.log('WebSocket connection failed. Falling back to long-polling.'); - socket.io.opts.transports = ['polling']; // Add polling transport - socket.io.engine.upgrade = false; // Disable further upgrades + console.warn('WebSocket connection failed. Falling back to long-polling.'); + socket.io.opts.transports = ['polling']; + socket.io.engine.upgrade = false; } });