diff --git a/settings.json.docker b/settings.json.docker index fbc1ea4f3..7f29e5dfc 100644 --- a/settings.json.docker +++ b/settings.json.docker @@ -535,7 +535,7 @@ /* * Restrict socket.io transport methods */ - "socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"], + "socketTransportProtocols" : ["polling", "websocket"], "socketIo": { /* diff --git a/settings.json.template b/settings.json.template index ea8f41812..233c631b1 100644 --- a/settings.json.template +++ b/settings.json.template @@ -535,7 +535,7 @@ /* * Restrict socket.io transport methods */ - "socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"], + "socketTransportProtocols" : ["polling", "websocket"], "socketIo": { /* diff --git a/src/node/hooks/express/socketio.js b/src/node/hooks/express/socketio.js index edb679940..978ea9bac 100644 --- a/src/node/hooks/express/socketio.js +++ b/src/node/hooks/express/socketio.js @@ -51,8 +51,8 @@ exports.expressCreateServer = (hookName, args, cb) => { // there shouldn't be a browser that isn't compatible to all // transports in this list at once // e.g. XHR is disabled in IE by default, so in IE it should use jsonp-polling - io = socketio({ - transports: settings.socketTransportProtocols, + io = new socketio.Server({ + transports: settings.socketTransportProtocols }).listen(args.server, { /* * Do not set the "io" cookie. @@ -106,14 +106,14 @@ exports.expressCreateServer = (hookName, args, cb) => { }); io.use((socket, next) => { - socket.conn.on('packet', (packet) => { + socket.conn.on('package', (packet) => { // Tell express-session that the session is still active. The session store can use these // touch events to defer automatic session cleanup, and if express-session is configured with // rolling=true the cookie's expiration time will be renewed. (Note that WebSockets does not // have a standard mechanism for periodically updating the browser's cookies, so the browser // will not see the new cookie expiration time unless it makes a new HTTP request or the new // cookie value is sent to the client in a custom socket.io message.) - if (socket.request.session != null) socket.request.session.touch(); + if (packet.request.session != null) packet.request.session.touch(); }); next(); }); diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index 512bc6f4c..5667c4032 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -121,7 +121,7 @@ exports.ssl = false; /** * socket.io transport methods **/ -exports.socketTransportProtocols = ['xhr-polling', 'jsonp-polling', 'htmlfile']; +exports.socketTransportProtocols = ["polling", "websocket"]; exports.socketIo = { /** diff --git a/src/static/js/socketio.js b/src/static/js/socketio.js index bf9cfd5d5..17cce08ec 100644 --- a/src/static/js/socketio.js +++ b/src/static/js/socketio.js @@ -19,7 +19,7 @@ const connect = (etherpadBaseUrl, namespace = '/', options = {}) => { const baseUrl = new URL(etherpadBaseUrl, window.location); const socketioUrl = new URL('socket.io', baseUrl); const namespaceUrl = new URL(namespace, new URL('/', baseUrl)); - return io(namespaceUrl.href, Object.assign({path: socketioUrl.pathname}, options)); + return new io.Socket(namespaceUrl.href, Object.assign({path: socketioUrl.pathname}, options)); }; if (typeof exports === 'object') { diff --git a/src/tests/backend/common.js b/src/tests/backend/common.js index a94ee74e9..dfc6d59e5 100644 --- a/src/tests/backend/common.js +++ b/src/tests/backend/common.js @@ -148,7 +148,7 @@ exports.connect = async (res = null) => { if (res) { padId = res.req.path.split('/p/')[1]; } - const socket = io(`${exports.baseUrl}/`, { + const socket = new io.Socket(`${exports.baseUrl}/`, { forceNew: true, // Different tests will have different query parameters. path: '/socket.io', // socketio.js-client on node.js doesn't support cookies (see https://git.io/JU8u9), so the