BUG fix REUSEADDR

This commit is contained in:
Luis Fernando Molina committed 2018-06-05 21:36:29 +02:00
1 parent 40ac581f3b
commit 4ee8328cac
3 files changed
+57 -33

No files matched your search

+8 -20
View File
@@ -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();
}
+26 -7
View File
@@ -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");
+23 -6
View File
@@ -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");