diff --git a/api/lib/ZnifferManager.ts b/api/lib/ZnifferManager.ts index 2ccfbfd52b2..14b33275539 100644 --- a/api/lib/ZnifferManager.ts +++ b/api/lib/ZnifferManager.ts @@ -105,6 +105,25 @@ export default class ZnifferManager extends TypedEventEmitter { + this.onError(error) + }) + + this.zniffer.on('frame', (frame, rawData) => { + const socketFrame = this.parseFrame(frame, rawData) + + this.socket.emit(socketEvents.znifferFrame, socketFrame) + }) + + this.zniffer.on('corrupted frame', (frame, rawData) => { + const socketFrame = this.parseFrame(frame, rawData) + + this.socket.emit(socketEvents.znifferFrame, socketFrame) + }) + + this.zniffer.on('ready', () => { + logger.info('Zniffer ready') + }) logger.info('Initing Zniffer...') this.init().catch(() => {}) @@ -113,33 +132,8 @@ export default class ZnifferManager extends TypedEventEmitter { - const socketFrame = this.parseFrame(frame, rawData) - - this.socket.emit(socketEvents.znifferFrame, socketFrame) - }) - - this.zniffer.on('corrupted frame', (frame, rawData) => { - const socketFrame = this.parseFrame(frame, rawData) - - this.socket.emit(socketEvents.znifferFrame, socketFrame) - }) - - this.zniffer.on('error', (error) => { - this.onError(error) - }) - - this.zniffer.on('ready', () => { - logger.info('Zniffer ready') - }) } catch (error) { - this.onError(error) - logger.info('Retrying in 5s...') - - await this.close() - this.restartTimeout = setTimeout(() => { this.init().catch(() => {}) }, 5000)