From c49c9ad4dece99572eb84701f3fca581b7ce8177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sat, 19 Jun 2021 20:20:46 +0200 Subject: [PATCH] reconnection add debug logs. --- src/component/internal/connection.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/component/internal/connection.ts b/src/component/internal/connection.ts index fbbd0e5c..e90322a9 100644 --- a/src/component/internal/connection.ts +++ b/src/component/internal/connection.ts @@ -156,9 +156,12 @@ export class NekoConnection extends EventEmitter { _websocketIsReconnecting = false _websocketReconnect() { if (this._websocketIsReconnecting) { + this._log.debug(`websocket reconnection already in progress`) return } + this._log.debug(`starting websocket reconnection`) + setTimeout(async () => { while (this._shouldReconnect) { try { @@ -166,11 +169,12 @@ export class NekoConnection extends EventEmitter { this._webrtcReconnect() break } catch (e) { - this._log.debug(`websocket reconnection`, e) + this._log.debug(`websocket reconnection failed`, e) } } this._websocketIsReconnecting = false + this._log.debug(`websocket reconnection finished`) }, 0) } @@ -185,21 +189,26 @@ export class NekoConnection extends EventEmitter { _webrtcReconnTimer?: number _webrtcReconnect() { if (this._webrtcReconnTimer) { + this._log.debug(`webrtc reconnection already in progress`) return } const lastVideo = this._state.webrtc.video ?? undefined + this._log.debug(`starting webrtc reconnection`) const reconnFunc = async () => { if (!this._shouldReconnect || !this.websocket.connected || this.webrtc.connected) { clearInterval(this._webrtcReconnTimer) this._webrtcReconnTimer = undefined + this._log.debug(`webrtc reconnection finished`) return } try { this._webrtcConnect(lastVideo) - } catch (e) {} + } catch (e) { + this._log.debug(`webrtc reconnection failed`, e) + } } this._webrtcReconnTimer = window.setInterval(reconnFunc, 1000)