Skip to content

Commit

Permalink
Merge pull request #1879 from ably/fix_RTN16D
Browse files Browse the repository at this point in the history
Ignore instance id when comparing connections keys
  • Loading branch information
owenpearson authored Sep 30, 2024
2 parents 8c9ce8b + 93c4059 commit 458c1ca
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion test/browser/connection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,24 @@ define(['shared_helper', 'chai'], function (Helper, chai) {
});
});

// strip instanceID and handleID from connectionKey */
function connectionHmac(key) {
/* connectionKey has the form <instanceID>!<hmac>-<handleID> */

/* remove the handleID from the end of key */
let k = key.split('-')[0];

/* skip the server instanceID if present, as reconnects may be routed to different frontends */
if (k.includes('!')) {
k = k.split('!')[1];
}
return k;
}

/* uses internal realtime knowledge of the format of the connection key to
* check if a connection key is the result of a successful recovery of another */
function sameConnection(keyA, keyB) {
return keyA.split('-')[0] === keyB.split('-')[0];
return connectionHmac(keyA) === connectionHmac(keyB);
}

/**
Expand Down

0 comments on commit 458c1ca

Please sign in to comment.