Fix error handling whenever Wazuh API is unreachable

This commit is contained in:
Jesús Ángel González 2018-04-20 14:10:46 +02:00
parent af0f58dc65
commit 9f90aae5ba
2 changed files with 3 additions and 4 deletions

View File

@ -48,7 +48,8 @@ const settingsWizard = ($rootScope, $location, $q, $window, testAPI, appState, g
let fromElastic = false;
if (parseInt(data.data.error) === 2){
errorHandler.handle('Wazuh App: Please set up Wazuh API credentials.','Routes',true);
} else if(data.data.data && data.data.data.apiIsDown){
} else if((data.data && (data.data.apiIsDown || data.data.message === 'socket hang up')) ||
(data.data.data && (data.data.data.apiIsDown || data.data.data.message === 'socket hang up'))){
$rootScope.apiIsDown = "down";
errorHandler.handle('Wazuh RESTful API seems to be down.','Routes');
} else {

View File

@ -118,9 +118,7 @@ class WazuhApi {
} catch(error){
console.log(error.message || error);
if(error.code === 'ECONNREFUSED'){
wapi_config.password = '****'
wapi_config.apiIsDown = true;
return reply({ statusCode: 200, data: wapi_config });
return reply({ statusCode: 200, data: {password: '****', apiIsDown: true } });
} else {
return reply({
statusCode: 500,