Skip to content

Commit aebbca5

Browse files
author
Datanoise
committed
fix: reduce player reconnect rate to ~1s with jitter
1 parent ff980c8 commit aebbca5

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

server/templates/player.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,16 @@
258258

259259
function reconnect() {
260260
if (isPlaying && !useWebRTC) {
261-
reconnectAttempts++;
262-
const delay = Math.min(1000 * Math.pow(1.5, reconnectAttempts), 10000);
261+
// Reconnect rate: ~1 second + tiny bit of random (0-200ms)
262+
const delay = 1000 + (Math.random() * 200);
263263
setTimeout(() => {
264264
if (!isPlaying) return;
265265
audio.src = mount + '?t=' + new Date().getTime();
266-
audio.play().then(() => reconnectAttempts = 0).catch(reconnect);
266+
audio.play().then(() => {
267+
reconnectAttempts = 0;
268+
}).catch(() => {
269+
reconnect();
270+
});
267271
}, delay);
268272
}
269273
}

0 commit comments

Comments
 (0)