From 6a1e70303db8f5edb637fc273d785d554dd7b723 Mon Sep 17 00:00:00 2001 From: padreug Date: Thu, 18 Sep 2025 10:25:17 +0200 Subject: [PATCH] Update WebSocket configuration and enhance logging in WalletWebSocketService - Modified WebSocket configuration to allow enabling/disabling via environment variable, improving flexibility. - Enhanced logging in WalletWebSocketService to provide clearer messages during reconnection attempts and notify users of WebSocket issues. These changes improve the configurability and user experience of the wallet's WebSocket interactions. --- src/app.config.ts | 2 +- src/modules/wallet/services/WalletWebSocketService.ts | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/app.config.ts b/src/app.config.ts index fdc0e52..a86fe96 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -76,7 +76,7 @@ export const appConfig: AppConfig = { baseUrl: import.meta.env.VITE_LNBITS_BASE_URL || 'http://localhost:5000' }, websocket: { - enabled: true, + enabled: import.meta.env.VITE_WEBSOCKET_ENABLED !== 'false', // Can be disabled via env var reconnectDelay: 1000, // 1 second maxReconnectAttempts: 5 } diff --git a/src/modules/wallet/services/WalletWebSocketService.ts b/src/modules/wallet/services/WalletWebSocketService.ts index 9fab90e..295ad21 100644 --- a/src/modules/wallet/services/WalletWebSocketService.ts +++ b/src/modules/wallet/services/WalletWebSocketService.ts @@ -308,8 +308,15 @@ export class WalletWebSocketService extends BaseService { private scheduleReconnect(): void { // Don't reconnect if we've exceeded max attempts if (this.reconnectAttempts >= this.config.maxReconnectAttempts) { - console.log('WalletWebSocketService: Max reconnection attempts reached') + console.log('WalletWebSocketService: Max reconnection attempts reached - disabling WebSocket') this.connectionStatus.value = 'failed' + + // Show user notification about WebSocket issues + if (this.toast) { + this.toast.info('Real-time balance updates temporarily unavailable', { + description: 'WebSocket connection failed. Balance will update on page refresh.' + }) + } return } @@ -322,7 +329,7 @@ export class WalletWebSocketService extends BaseService { const delay = this.config.reconnectDelay * Math.pow(2, this.reconnectAttempts) this.reconnectAttempts++ - console.log(`WalletWebSocketService: Reconnecting in ${delay}ms (attempt ${this.reconnectAttempts})`) + console.log(`WalletWebSocketService: Reconnecting in ${delay}ms (attempt ${this.reconnectAttempts}/${this.config.maxReconnectAttempts})`) this.connectionStatus.value = 'reconnecting' this.reconnectTimer = setTimeout(() => {