scaling: include padId in socketio query string

This commit is contained in:
John McLear 2021-03-24 16:07:11 +00:00 committed by GitHub
parent 0e854a5892
commit 2b98b930d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View file

@ -218,7 +218,14 @@ const sendClientReady = (isReconnect, messageType) => {
};
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, '/', {
query: {padId},
reconnectionAttempts: 5,
reconnection: true,
reconnectionDelay: 1000,

View file

@ -52,7 +52,7 @@ const init = () => {
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
socket.on('connect', () => {