fixes and tweaks. implemented polling reload on HB loss

pull/111/merge
Ondřej Hruška 7 years ago
parent a82e14961c
commit daba5340f7
  1. 2
      esphttpdconfig.mk
  2. 18
      html_orig/js/app.js
  3. 18
      html_orig/jssrc/term.js
  4. 2
      libesphttpd
  5. 2
      user/cgi_sockets.c

@ -50,7 +50,7 @@ GLOBAL_CFLAGS = \
-DDEBUG_ANSI=1 \ -DDEBUG_ANSI=1 \
-DDEBUG_ANSI_NOIMPL=1 \ -DDEBUG_ANSI_NOIMPL=1 \
-DHTTPD_MAX_BACKLOG_SIZE=8192 \ -DHTTPD_MAX_BACKLOG_SIZE=8192 \
-DHTTPD_MAX_HEAD_LEN=512 \ -DHTTPD_MAX_HEAD_LEN=1024 \
-DHTTPD_MAX_POST_LEN=512 \ -DHTTPD_MAX_POST_LEN=512 \
-DDEBUG_INPUT=0 \ -DDEBUG_INPUT=0 \
-DDEBUG_HEAP=1 \ -DDEBUG_HEAP=1 \

@ -1958,6 +1958,7 @@ var Screen = (function () {
var Conn = (function() { var Conn = (function() {
var ws; var ws;
var heartbeatTout; var heartbeatTout;
var pingIv;
function onOpen(evt) { function onOpen(evt) {
console.log("CONNECTED"); console.log("CONNECTED");
@ -2023,12 +2024,23 @@ var Conn = (function() {
function heartbeat() { function heartbeat() {
clearTimeout(heartbeatTout); clearTimeout(heartbeatTout);
heartbeatTout = setTimeout(heartbeatFail, 3000); heartbeatTout = setTimeout(heartbeatFail, 2000);
} }
function heartbeatFail() { function heartbeatFail() {
console.error("Heartbeat lost, reloading..."); console.error("Heartbeat lost, probing server...");
location.reload(); pingIv = setInterval(function() {
console.log("> ping");
$.get('http://'+_root+'/system/ping', function(resp, status) {
if (status == 200) {
clearInterval(pingIv);
console.info("Server ready, reloading page...");
location.reload();
}
}, {
timeout: 100,
});
}, 500);
} }
return { return {

@ -392,6 +392,7 @@ var Screen = (function () {
var Conn = (function() { var Conn = (function() {
var ws; var ws;
var heartbeatTout; var heartbeatTout;
var pingIv;
function onOpen(evt) { function onOpen(evt) {
console.log("CONNECTED"); console.log("CONNECTED");
@ -457,12 +458,23 @@ var Conn = (function() {
function heartbeat() { function heartbeat() {
clearTimeout(heartbeatTout); clearTimeout(heartbeatTout);
heartbeatTout = setTimeout(heartbeatFail, 3000); heartbeatTout = setTimeout(heartbeatFail, 2000);
} }
function heartbeatFail() { function heartbeatFail() {
console.error("Heartbeat lost, reloading..."); console.error("Heartbeat lost, probing server...");
location.reload(); pingIv = setInterval(function() {
console.log("> ping");
$.get('http://'+_root+'/system/ping', function(resp, status) {
if (status == 200) {
clearInterval(pingIv);
console.info("Server ready, reloading page...");
location.reload();
}
}, {
timeout: 100,
});
}, 500);
} }
return { return {

@ -1 +1 @@
Subproject commit 566e95af0c892576825903303ca7c65710cbbb5e Subproject commit 13fa224963081e9ff298abd74a59faafcb9bf816

@ -11,7 +11,7 @@
#define LOOPBACK 0 #define LOOPBACK 0
#define HB_TIME 1500 #define HB_TIME 1000
#define SOCK_BUF_LEN 2000 #define SOCK_BUF_LEN 2000

Loading…
Cancel
Save