From 054f81ee7b98432d013a7810ae5291b889df5540 Mon Sep 17 00:00:00 2001 From: Timon G Date: Mon, 26 Jul 2021 16:03:14 +0200 Subject: [PATCH] first test to narrow down problem (#2089) --- src/app/bottom-bar/bottom-bar.component.ts | 3 +++ src/app/model/printer.model.ts | 1 + src/app/services/socket/socket.octoprint.service.ts | 8 +++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/bottom-bar/bottom-bar.component.ts b/src/app/bottom-bar/bottom-bar.component.ts index 86fa06c19..438d86c52 100644 --- a/src/app/bottom-bar/bottom-bar.component.ts +++ b/src/app/bottom-bar/bottom-bar.component.ts @@ -55,6 +55,9 @@ export class BottomBarComponent implements OnDestroy { } public getStringStatus(printerState: PrinterState): string { + if (printerState === PrinterState.socketDead) { + return 'socket is dead'; + } return PrinterState[printerState]; } diff --git a/src/app/model/printer.model.ts b/src/app/model/printer.model.ts index ce0992aca..ccc402616 100644 --- a/src/app/model/printer.model.ts +++ b/src/app/model/printer.model.ts @@ -20,4 +20,5 @@ export enum PrinterState { closed, connecting, reconnecting, + socketDead, } diff --git a/src/app/services/socket/socket.octoprint.service.ts b/src/app/services/socket/socket.octoprint.service.ts index b51124c56..a0a5d4afb 100644 --- a/src/app/services/socket/socket.octoprint.service.ts +++ b/src/app/services/socket/socket.octoprint.service.ts @@ -21,6 +21,7 @@ import { SocketService } from './socket.service'; @Injectable() export class OctoPrintSocketService implements SocketService { private fastInterval = 0; + private socketDeadTimeout: ReturnType; private socket: WebSocketSubject; private printerStatusSubject: Subject; @@ -119,6 +120,11 @@ export class OctoPrintSocketService implements SocketService { private setupSocket(resolve: () => void) { this.socket.subscribe( message => { + clearTimeout(this.socketDeadTimeout); + this.socketDeadTimeout = setTimeout(() => { + this.printerStatus.status = PrinterState.socketDead; + this.printerStatusSubject.next(this.printerStatus); + }, 30000); if (Object.hasOwnProperty.bind(message)('current')) { this.extractPrinterStatus(message as OctoprintSocketCurrent); this.extractJobStatus(message as OctoprintSocketCurrent); @@ -133,7 +139,7 @@ export class OctoPrintSocketService implements SocketService { this.extractFanSpeed(pluginMessage.plugin.data as DisplayLayerProgressData); this.extractLayerHeight(pluginMessage.plugin.data as DisplayLayerProgressData); } - } else if (Object.hasOwnProperty.bind(message)('reauth')) { + } else if (Object.hasOwnProperty.bind(message)('reauthRequired')) { this.systemService.getSessionKey().subscribe(socketAuth => this.authenticateSocket(socketAuth)); } else if (Object.hasOwnProperty.bind(message)('connected')) { resolve();