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(() => {