summary refs log tree commit diff
diff options
context:
space:
mode:
authordank074 <torresefrain10@gmail.com>2026-01-30 20:51:50 -0600
committerdank074 <torresefrain10@gmail.com>2026-01-30 20:51:50 -0600
commit7d1e8ce084cd96dd1399c5aa3423d646dc6650d0 (patch)
tree1bcc74ec0affddf342885828d151a8ebeeae907c
parentsimplify reconnect delay and shorten time (diff)
downloadserver-ts-7d1e8ce084cd96dd1399c5aa3423d646dc6650d0.tar.xz
remove jitter from delay calculation altogether
-rw-r--r--src/util/util/RabbitMQ.ts12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/util/util/RabbitMQ.ts b/src/util/util/RabbitMQ.ts

index e60999d3..67d0cec0 100644 --- a/src/util/util/RabbitMQ.ts +++ b/src/util/util/RabbitMQ.ts
@@ -30,8 +30,7 @@ export class RabbitMQ { // Reconnection state private static isReconnecting = false; private static reconnectAttempts = 0; - private static readonly MAX_RECONNECT_DELAY_MS = 5000; // Max 5 seconds between retries - private static readonly BASE_RECONNECT_DELAY_MS = 500; // Start with 500 milliseconds + private static readonly BASE_RECONNECT_DELAY_MS = 500; // reconnect after 500 milliseconds delay // Track if event listeners have been set up (to avoid duplicates) private static connectionListenersAttached = false; @@ -117,14 +116,9 @@ export class RabbitMQ { this.isReconnecting = true; this.reconnectAttempts++; - // add random jitter to reconnection delay - const baseDelay = Math.min(this.BASE_RECONNECT_DELAY_MS + Math.random() * 2000, this.MAX_RECONNECT_DELAY_MS); + console.log(`[RabbitMQ] Scheduling reconnection attempt ${this.reconnectAttempts} in ${this.BASE_RECONNECT_DELAY_MS}ms`); - const delay = Math.round(baseDelay); - - console.log(`[RabbitMQ] Scheduling reconnection attempt ${this.reconnectAttempts} in ${delay}ms`); - - await new Promise((resolve) => setTimeout(resolve, delay)); + await new Promise((resolve) => setTimeout(resolve, this.BASE_RECONNECT_DELAY_MS)); try { await this.connect(host);