From ceb17a5999e65201bcbebd8e227fc19bfa3ba80e Mon Sep 17 00:00:00 2001 From: Mohamad Ihsan Date: Fri, 25 Aug 2023 10:41:54 +0700 Subject: [PATCH] update --- application/modules/hsm/authenticate2.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/application/modules/hsm/authenticate2.js b/application/modules/hsm/authenticate2.js index 4425d66..5a4aaf2 100644 --- a/application/modules/hsm/authenticate2.js +++ b/application/modules/hsm/authenticate2.js @@ -86,8 +86,11 @@ const controller = async (req, res) => { useClient.sendData(reqData); - let respData = null; - let respData1 = null; + setInterval(function () { + respData = Buffer.from([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]); + _timeOut = true; + }, 10000); + useClient.ws.on('message', (message) => { while ( message[2] == 2 && @@ -114,6 +117,23 @@ const controller = async (req, res) => { await _sleep(10); } + if (_timeOut) { + result = { + code: '5001', + message: 'Timeout', + data: {}, + }; + + // log warn + winston.logger.warn( + `${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-2 ]: message from HSM ${JSON.stringify( + result + )}` + ); + + return res.status(200).send(result); + } + _stopMessage = 0; transactionId[0] = respData[0];