From 4ee8328cacf2136f753f247896ab18fb2f0a7972 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 5 Jun 2018 21:36:29 +0200 Subject: [PATCH] BUG fix REUSEADDR --- AzureStorage.js | 28 ++++++++-------------------- ExtractionBotProcessMainLoop.js | 33 ++++++++++++++++++++++++++------- IndicatorBotProcessMainLoop.js | 29 +++++++++++++++++++++++------ 3 files changed, 57 insertions(+), 33 deletions(-) diff --git a/AzureStorage.js b/AzureStorage.js index a69617887..f1222ed26 100644 --- a/AzureStorage.js +++ b/AzureStorage.js @@ -128,9 +128,10 @@ let options = { host: pEndPoint, port: 443, - path: '/' + pContainer + '/' + pBlobPath + '?' + pSAS, + path: '/' + pContainer + '/' + pBlobPath + '?' + pSAS + '&timeout=30', method: 'GET', - headers: {} + headers: {}, + agent: false } let responseData = ''; @@ -140,7 +141,7 @@ /* We add the headers. */ options.headers['x-ms-version'] = '2017-07-29'; - options.headers['Connection'] = 'Keep-Alive'; + //options.headers['Connection'] = 'Keep-Alive'; /* Making the https get call. */ @@ -160,28 +161,17 @@ } function onResponse(response) { - console.log("\nstatus code: ", response.statusCode); response.on('data', onPieceOfDataArrived); response.on('end', onAllDataArrived); } function onPieceOfDataArrived(pData) { - console.log('New Data Arrived!'); - console.log(pData.toString()); responseData = responseData + pData.toString(); } function onAllDataArrived() { - try { - let obj = JSON.parse(responseData); - } - catch (err) { - - console.log("Cannot parse this."); - } - callBack(err, responseData) } @@ -192,9 +182,10 @@ let options = { host: pEndPoint, port: 443, - path: '/' + pContainer + '/' + pBlobPath + '?' + pSAS, + path: '/' + pContainer + '/' + pBlobPath + '?' + pSAS + '&timeout=30', method: 'PUT', - headers: {} + headers: {}, + agent: false } let responseData = ''; @@ -207,7 +198,7 @@ options.headers['x-ms-version'] = '2017-07-29'; options.headers['Content-Length'] = pBlobContent.length; options.headers['x-ms-blob-type'] = 'BlockBlob'; - options.headers['Connection'] = 'Keep-Alive'; + //options.headers['Connection'] = 'Keep-Alive'; /* Making the https get call. */ @@ -243,9 +234,6 @@ } function onPieceOfDataArrived(pData) { - console.log('New Data Arrived!'); - console.log(pData.toString()); - responseData = responseData + pData.toString(); } diff --git a/ExtractionBotProcessMainLoop.js b/ExtractionBotProcessMainLoop.js index f8309b91b..c0970ed02 100644 --- a/ExtractionBotProcessMainLoop.js +++ b/ExtractionBotProcessMainLoop.js @@ -288,6 +288,32 @@ callBackFunction(err); return; } + case global.CUSTOM_OK_RESPONSE.result: { + + switch (err.message) { + case "Too far in the future.": { + logger.write("[WARN] run -> loop -> initializeUserBot -> onInizialized > Too far in the future. This Loop will enter in coma."); + nextWaitTime = 'Coma'; + clearInterval(intervalHandle); + loopControl(nextWaitTime); + return; + } + case "Not needed now, but soon.": { + logger.write("[WARN] run -> loop -> initializeUserBot -> onInizialized > Not needed now, but soon. This Loop will continue with Normal wait time."); + nextWaitTime = 'Normal'; + clearInterval(intervalHandle); + loopControl(nextWaitTime); + return; + } + default: { + logger.write("[ERROR] run -> loop -> initializeUserBot -> onInizialized > Unhandled custom response received. -> err.message = " + err.message); + bot.eventHandler.raiseEvent("Close Log File"); + clearInterval(intervalHandle); + callBackFunction(err); + return; + } + } + } default: { logger.write("[ERROR] run -> loop -> initializeUserBot -> onInizialized > Unhandled err.result received. -> err.result = " + err.result); logger.write("[ERROR] run -> loop -> initializeUserBot -> onInizialized > Unhandled err.result received. -> err.message = " + err.message); @@ -385,13 +411,6 @@ callBackFunction(global.DEFAULT_OK_RESPONSE); return; } - case "Too far in the future.": { - logger.write("[WARN] run -> loop -> startUserBot -> onFinished > Too far in the future. This Loop will enter in coma."); - nextWaitTime = 'Coma'; - clearInterval(intervalHandle); - loopControl(nextWaitTime); - return; - } default: { logger.write("[ERROR] run -> loop -> startUserBot -> onFinished > Unhandled custom response received. -> err.message = " + err.message); bot.eventHandler.raiseEvent("Close Log File"); diff --git a/IndicatorBotProcessMainLoop.js b/IndicatorBotProcessMainLoop.js index 789269f0a..676d16594 100644 --- a/IndicatorBotProcessMainLoop.js +++ b/IndicatorBotProcessMainLoop.js @@ -283,6 +283,29 @@ callBackFunction(err); return; } + case global.CUSTOM_OK_RESPONSE.result: { + + switch (err.message) { + case "Too far in the future.": { + logger.write("[WARN] run -> loop -> initializeUserBot -> onInizialized > Too far in the future. This Loop will enter in coma."); + nextWaitTime = 'Coma'; + loopControl(nextWaitTime); + return; + } + case "Not needed now, but soon.": { + logger.write("[WARN] run -> loop -> initializeUserBot -> onInizialized > Not needed now, but soon. This Loop will continue with Normal wait time."); + nextWaitTime = 'Normal'; + loopControl(nextWaitTime); + return; + } + default: { + logger.write("[ERROR] run -> loop -> initializeUserBot -> onInizialized > Unhandled custom response received. -> err.message = " + err.message); + bot.eventHandler.raiseEvent("Close Log File"); + callBackFunction(err); + return; + } + } + } default: { logger.write("[ERROR] run -> loop -> initializeUserBot -> onInizialized -> Unhandled err.result received. -> err.result = " + err.result); logger.write("[ERROR] run -> loop -> initializeUserBot -> onInizialized -> Unhandled err.result received. -> err.message = " + err.message); @@ -373,12 +396,6 @@ callBackFunction(global.DEFAULT_OK_RESPONSE); return; } - case "Too far in the future.": { - logger.write("[WARN] run -> loop -> startUserBot -> onFinished -> Too far in the future. This Loop will enter in coma."); - nextWaitTime = 'Coma'; - loopControl(nextWaitTime); - return; - } default: { logger.write("[ERROR] run -> loop -> startUserBot -> onFinished -> Unhandled custom response received. -> err.message = " + err.message); bot.eventHandler.raiseEvent("Close Log File");