From 343177293d6c9d2e3822b0fe0b901a11774ca056 Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Fri, 17 May 2024 17:36:31 +0100 Subject: [PATCH] add error output for connection drop --- src/classes/insightsConnection.ts | 12 ++++++++++-- src/services/connectionManagerService.ts | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/classes/insightsConnection.ts b/src/classes/insightsConnection.ts index eff20086..8b1e3708 100644 --- a/src/classes/insightsConnection.ts +++ b/src/classes/insightsConnection.ts @@ -453,6 +453,7 @@ export class InsightsConnection { const body = { labels: {}, }; + const startTime = Date.now(); return await axios .request({ @@ -460,15 +461,22 @@ export class InsightsConnection { url: pingURL.toString(), data: body, headers: { Authorization: `Bearer ${userToken.accessToken}` }, - timeout: 1000, + timeout: 2000, }) .then((_response: any) => { Telemetry.sendEvent("Insights.Pinged"); return true; }) .catch((_error: any) => { + const endTime = Date.now(); + const timeString = new Date().toLocaleTimeString(); + const timeDiff = endTime - startTime; + ext.outputChannel.appendLine( + `[${timeString}] Connection keep alive error: ${this.connLabel}. Ping failed. ${_error.code}: status code ${_error.response.status}. Time Elapsed ${timeDiff}ms`, + ); + window.showErrorMessage( - `The Insights connection: ${this.connLabel} cannot be reached, the connection closed.`, + `Error in connection: ${this.connLabel}, check kdb OUTPUT for more info.`, ); return false; }); diff --git a/src/services/connectionManagerService.ts b/src/services/connectionManagerService.ts index c7f7acc6..80269933 100644 --- a/src/services/connectionManagerService.ts +++ b/src/services/connectionManagerService.ts @@ -259,7 +259,7 @@ export class ConnectionManagementService { } Telemetry.sendEvent("Connection.Disconnected." + connType); ext.outputChannel.appendLine( - `Connection stopped from ${connection.connLabel}`, + `[${new Date().toLocaleTimeString()}] Connection disconnected: ${connection.connLabel}`, ); ext.serverProvider.reload(); } @@ -376,6 +376,6 @@ export class ConnectionManagementService { } else { clearInterval(intervalConns); } - }, 60000); + }, 120000); } }