diff --git a/frontend/src/app/services/websocket.service.ts b/frontend/src/app/services/websocket.service.ts index 22da49f06..1e7f528eb 100644 --- a/frontend/src/app/services/websocket.service.ts +++ b/frontend/src/app/services/websocket.service.ts @@ -76,17 +76,22 @@ export class WebsocketService { this.stateService.resetChainTip(); - this.websocketSubject.complete(); - this.subscription.unsubscribe(); - this.websocketSubject = webSocket( - this.webSocketUrl.replace('{network}', this.network ? '/' + this.network : '') - ); - - this.startSubscription(); + this.reconnectWebsocket(); }); } } + reconnectWebsocket(retrying = false, hasInitData = false) { + console.log('reconnecting websocket'); + this.websocketSubject.complete(); + this.subscription.unsubscribe(); + this.websocketSubject = webSocket( + this.webSocketUrl.replace('{network}', this.network ? '/' + this.network : '') + ); + + this.startSubscription(retrying, hasInitData); + } + startSubscription(retrying = false, hasInitData = false) { if (!hasInitData) { this.stateService.isLoadingWebSocket$.next(true); @@ -237,7 +242,7 @@ export class WebsocketService { this.goneOffline = true; this.stateService.connectionState$.next(0); window.setTimeout(() => { - this.startSubscription(true); + this.reconnectWebsocket(true); }, retryDelay); }