From a6709133202f3a96ab00795812b3b4b867efd6a6 Mon Sep 17 00:00:00 2001 From: arc-alex Date: Wed, 8 Nov 2023 10:48:09 +0100 Subject: [PATCH] simplify retun path --- .../integration-service/HttpIntegration.ts | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/apps/server/src/services/integration-service/HttpIntegration.ts b/apps/server/src/services/integration-service/HttpIntegration.ts index 105be47f1..a3e0f5ecc 100644 --- a/apps/server/src/services/integration-service/HttpIntegration.ts +++ b/apps/server/src/services/integration-service/HttpIntegration.ts @@ -10,7 +10,6 @@ import { validateHttpObject } from '../../utils/parserFunctions.js'; import { logger } from '../../classes/Logger.js'; import { URL } from 'node:url'; - type Action = TimerLifeCycleKey | string; /** @@ -39,7 +38,9 @@ export class HttpIntegration implements IIntegration { this.httpAgent?.destroy(); // this.httpAgent = new http.Agent({ keepAlive: true, timeout: 2000, maxSockets: 5, maxFreeSockets: 40 }); //TODO: find the correct settings - this.httpAgent = new http.Agent({ keepAlive: true, timeout: 1000, maxFreeSockets: 1, maxSockets: 1}); + // this.httpAgent = new http.Agent({ keepAlive: true, timeout: 1000, maxFreeSockets: 10, maxSockets: 5}); + this.httpAgent = new http.Agent({ keepAlive: false, timeout: 1000 }); + // this.httpAgent = new http.Agent(); return { success: true, message: `HTTP integration client ready`, @@ -90,22 +91,13 @@ export class HttpIntegration implements IIntegration { }); } - emit(path: URL) { + async emit(path: URL) { http .get(path, { agent: this.httpAgent }, (res) => { - if (res.statusCode < 300) { - res.resume(); - return { - success: true, - message: 'HTTP Message sent', - }; - } else { - res.resume(); - return { - success: false, - message: `Error sending message responds: ${res.statusCode}`, - }; + if (res.statusCode !== 200) { + logger.error(LogOrigin.Tx, `HTTP Error: ${res.statusCode}`); } + res.resume(); }) .on('error', (err) => { logger.error(LogOrigin.Tx, `HTTP integration: ${err}`);