Project

General

Profile

Bug #5227 » 0001-Reduce-overhead-of-websocket-connection-failures.patch

Bruce Toll, 08/30/2016 04:15 PM

View differences:

src/web/skeleton/Wt.js
state: WebSocketUnknown,
socket: null,
keepAlive: null,
reconnectTries: 0
reconnectTries: 0,
successCount: 0
};
var connectionMonitor = null;
......
if (ws != null && websocket.state == WebSocketUnknown)
websocket.state = WebSocketUnavailable;
else {
function reconnect() {
if (!hasQuit) {
++websocket.reconnectTries;
var ms = Math.min(120000, Math.exp(websocket.reconnectTries)
* 500);
setTimeout(function() { scheduleUpdate(); }, ms);
}
}
var protocolEnd = sessionUrl.indexOf("://"), wsurl;
if (protocolEnd != -1) {
wsurl = "ws" + sessionUrl.substr(4);
......
connectionMonitor.onStatusChange('connectionStatus', 1);
}
websocket.state = WebSocketWorking;
++websocket.successCount;
js = event.data;
}
......
*/
if (connectionMonitor)
connectionMonitor.onStatusChange('websocket', false);
if (websocket.reconnectTries == 3 &&
websocket.state == WebSocketUnknown)
if (websocket.reconnectTries >= 3 &&
websocket.successCount == 0)
websocket.state = WebSocketUnavailable;
reconnect();
++websocket.reconnectTries;
return;
};
ws.onclose = function(event) {
......
*/
if (connectionMonitor)
connectionMonitor.onStatusChange('websocket', false);
if (websocket.reconnectTries == 3 &&
websocket.state == WebSocketUnknown)
if (websocket.reconnectTries >= 3 &&
websocket.successCount == 0)
websocket.state = WebSocketUnavailable;
reconnect();
++websocket.reconnectTries;
return;
};
ws.onopen = function(event) {
(1-1/3)