diff --git a/dashboard/js/app.jsx b/dashboard/js/app.jsx index 3ccc42a..d3e402a 100644 --- a/dashboard/js/app.jsx +++ b/dashboard/js/app.jsx @@ -9,6 +9,12 @@ var Dashboard = React.createClass({ reload: function() { getURL("http://127.0.0.1:6464/stats.json", {}, function(resp) { + if (resp.error !== undefined) { + console.log("Stats server is offline"); + setTimeout(this.reload, 3000); + return + } + var newState = {}; var decode = function(point) { return { diff --git a/dashboard/js/http.js b/dashboard/js/http.js index 9acc202..1ee94f6 100644 --- a/dashboard/js/http.js +++ b/dashboard/js/http.js @@ -31,7 +31,6 @@ function getURL(url, params, callback) { } var xhr = getXHR(); - xhr.open('GET', url, true); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { if(xhr.status === 200) { @@ -39,10 +38,10 @@ function getURL(url, params, callback) { } } }; - - try { - xhr.send(null); - } catch (e) { + xhr.onerror = function(e) { callback({error: e}); - } + }; + + xhr.open('GET', url, true); + xhr.send(null); }