2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-13 23:36:37 +00:00

fhemweb.js: fix error if FHEM is behind proxy and is dead (Forum #64672)

git-svn-id: https://svn.fhem.de/fhem/trunk@13125 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2017-01-17 16:10:17 +00:00
parent 88c4e5c1a4
commit 1c98891a5e

View File

@ -741,6 +741,12 @@ FW_doUpdate(evt)
log("Rcvd: "+(l.length>132 ? l.substring(0,132)+"...("+l.length+")":l));
if(!l.length)
continue;
if(l.indexOf("<")== 0) { // HTML returned by proxy, if FHEM behind is dead
FW_closeConn();
FW_errmsg(errstr, retryTime-100);
setTimeout(FW_longpoll, retryTime);
return;
}
var d = JSON.parse(l);
if(d.length != 3)
continue;
@ -788,20 +794,26 @@ FW_doUpdate(evt)
FW_longpoll();
}
function
FW_closeConn()
{
FW_leaving = 1;
if(!FW_pollConn)
return;
if(typeof FW_pollConn.close == "function")
FW_pollConn.close();
else if(typeof FW_pollConn.abort == "function")
FW_pollConn.abort();
FW_pollConn = undefined;
}
function
FW_longpoll()
{
FW_longpollOffset = 0;
if(FW_pollConn) {
FW_leaving = 1;
if(FW_longpollType == "websocket")
FW_pollConn.close();
else
FW_pollConn.abort();
FW_pollConn = undefined;
}
FW_closeConn();
FW_leaving = 0;
FW_longpollOffset = 0;
// Build the notify filter for the backend
var filter = $("body").attr("longpollfilter");