mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
scaling: include padId in socketio query string
This commit is contained in:
parent
0e854a5892
commit
2b98b930d7
3 changed files with 10 additions and 2 deletions
|
@ -218,7 +218,14 @@ const sendClientReady = (isReconnect, messageType) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handshake = () => {
|
const handshake = () => {
|
||||||
|
let padId = document.location.pathname.substring(document.location.pathname.lastIndexOf('/') + 1);
|
||||||
|
// unescape neccesary due to Safari and Opera interpretation of spaces
|
||||||
|
padId = decodeURIComponent(padId);
|
||||||
|
|
||||||
|
// padId is used here for sharding / scaling. We prefix the padId with padId: so it's clear
|
||||||
|
// to the proxy/gateway/whatever that this is a pad connection and should be treated as such
|
||||||
socket = pad.socket = socketio.connect(exports.baseURL, '/', {
|
socket = pad.socket = socketio.connect(exports.baseURL, '/', {
|
||||||
|
query: {padId},
|
||||||
reconnectionAttempts: 5,
|
reconnectionAttempts: 5,
|
||||||
reconnection: true,
|
reconnection: true,
|
||||||
reconnectionDelay: 1000,
|
reconnectionDelay: 1000,
|
||||||
|
|
|
@ -52,7 +52,7 @@ const init = () => {
|
||||||
Cookies.set('token', token, {expires: 60});
|
Cookies.set('token', token, {expires: 60});
|
||||||
}
|
}
|
||||||
|
|
||||||
socket = socketio.connect(exports.baseURL);
|
socket = socketio.connect(exports.baseURL, '/', {query: {padId}});
|
||||||
|
|
||||||
// send the ready message once we're connected
|
// send the ready message once we're connected
|
||||||
socket.on('connect', () => {
|
socket.on('connect', () => {
|
||||||
|
|
|
@ -52,12 +52,13 @@ const connect = async (res) => {
|
||||||
([name, cookie]) => `${name}=${encodeURIComponent(cookie.value)}`).join('; ');
|
([name, cookie]) => `${name}=${encodeURIComponent(cookie.value)}`).join('; ');
|
||||||
|
|
||||||
logger.debug('socket.io connecting...');
|
logger.debug('socket.io connecting...');
|
||||||
|
const padId = res.req.path.split('/p/')[1];
|
||||||
const socket = io(`${common.baseUrl}/`, {
|
const socket = io(`${common.baseUrl}/`, {
|
||||||
forceNew: true, // Different tests will have different query parameters.
|
forceNew: true, // Different tests will have different query parameters.
|
||||||
path: '/socket.io',
|
path: '/socket.io',
|
||||||
// socketio.js-client on node.js doesn't support cookies (see https://git.io/JU8u9), so the
|
// socketio.js-client on node.js doesn't support cookies (see https://git.io/JU8u9), so the
|
||||||
// express_sid cookie must be passed as a query parameter.
|
// express_sid cookie must be passed as a query parameter.
|
||||||
query: {cookie: reqCookieHdr},
|
query: {cookie: reqCookieHdr, padId},
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await getSocketEvent(socket, 'connect');
|
await getSocketEvent(socket, 'connect');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue