Closed gabriel-vasile closed 2 years ago
The "code":503,"text":"locked"
is exactly how it's supposed to work if an attempt to subscribe is made within 5 seconds after unsubscribing.
Please describe a legitimate use case when subscribe must happen within 5 seconds after unsubscribe.
Just sleep(5s)
before the last subscribe
:
<!DOCTYPE html>
<html lang="en">
<head>
<script crossorigin="anonymous"
src="https://cdn.jsdelivr.net/npm/tinode-sdk/umd/tinode.dev.js">
</script>
<meta charset="UTF-8">
</head>
<body id="home">
<h1>HTML5 boilerplate</h1>
<script>
u1 = {
u: "alice",
p: "alice123",
}
u2 = {
u: "bob",
p: "bob123",
}
t1 = new Tinode({
host: "localhost:6060",
apiKey: "AQEAAAABAAD_rAp4DJh05a1HAwFT3A6K",
});
t2 = new Tinode({
host: "localhost:6060",
apiKey: "AQEAAAABAAD_rAp4DJh05a1HAwFT3A6K",
});
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function run() {
await t1.connect()
await t1.loginBasic(u1.u, u1.p)
await t2.connect()
await t2.loginBasic(u2.u, u2.p)
await t1.subscribe(t2.getCurrentUserID())
await t2.subscribe(t1.getCurrentUserID())
await t1.leave(t2.getCurrentUserID(), true)
await t2.leave(t1.getCurrentUserID(), true)
await sleep(5100)
await t1.subscribe(t2.getCurrentUserID())
}
run()
</script>
</body>
</html>
I2022/05/09 08:59:03 in: '{"sub":{"id":"93280","topic":"usrrgaRT_86T54"}}' sid='K6pyAl_hyF8' uid='PHFQgtoIMfQ'
E2022/05/09 08:59:03 hub: missing both subscriptions for 'p2prgaRT_86T548cVCC2ggx9A' (SHOULD NEVER HAPPEN!)
E2022/05/09 08:59:03 init_topic: failed to load or create topic: p2prgaRT_86T548cVCC2ggx9A internal
Duplicate of #738
tinode version: 0.18.5
After this fix P2P conversations cannot be restored after both users
{leave unsub=true}
.To reproduce, start with a fresh install of sandbox tinode and run reproduce.html in browser. reproduce.html:
expected: last subscribe in reproduce.html runs successfully and conversation is restored with previous messages. got: last subscribe gives
{"ctrl":{"id":"118029","topic":"usrrLRncQTBnDg","code":503,"text":"locked","ts":"2022-05-04T08:29:31.127Z"}}
user1 logs:
user2 logs: