From 118d149f2e29330d350dabffdfd8b6794ec56125 Mon Sep 17 00:00:00 2001 From: Julian Waller Date: Mon, 1 Feb 2021 19:10:10 +0000 Subject: [PATCH] fix: opening connection to localhost before target at starutp --- src/client.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/client.ts b/src/client.ts index 73b3c25..c5bef92 100644 --- a/src/client.ts +++ b/src/client.ts @@ -50,7 +50,9 @@ export class CompanionSatelliteClient extends EventEmitter this.emit('error', e)) + this.socket.on('error', (e) => { + this.emit('error', e) + }) this.socket.on('close', () => { if (this.debug) { this.emit('log', 'Connection closed') @@ -105,13 +107,17 @@ export class CompanionSatelliteClient extends EventEmitter PING_UNACKED_LIMIT) { // Ping was never acked, so it looks like a timeout + this.emit('log', 'ping timeout') try { this.socket.destroy() } catch (e) { @@ -170,6 +176,8 @@ export class CompanionSatelliteClient extends EventEmitter 0) { const header = Protocol.readHeader(this.receiveBuffer) @@ -181,7 +189,7 @@ export class CompanionSatelliteClient extends EventEmitter 0) { + console.debug(`Out of sync, skipped ${ignoredBytes} bytes of data`) + ignoredBytes = 0 + } + if (this.receiveBuffer.length < header.length + 6) { // not enough data yet break