Workaround for broken websocket ping/pong implementation in browsers

Now use a normal message to keep the connection alive. Avoids the
annoying error messages in the console when the browser times out the
connection.
This commit is contained in:
Kovid Goyal 2016-04-08 10:57:37 +05:30
parent 388c6859bb
commit 3e70e190dd
2 changed files with 3 additions and 3 deletions

View File

@ -33,7 +33,7 @@
}; };
self.ws.onmessage = function(event) { self.ws.onmessage = function(event) {
console.log('Received mesasge from reload server: ' + event.data); if (event.data !== 'ping') console.log('Received mesasge from reload server: ' + event.data);
if (event.data === 'reload') window.location.reload(true); if (event.data === 'reload') window.location.reload(true);
}; };

View File

@ -253,7 +253,7 @@ class Worker(object):
def ping_thread(self): def ping_thread(self):
while True: while True:
self.server.ping() self.server.ping()
time.sleep(0.9 * self.connection_timeout) time.sleep(30)
def __enter__(self): def __enter__(self):
self.restart() self.restart()
@ -341,7 +341,7 @@ class ReloadHandler(DummyHandler):
for connref in self.connections.itervalues(): for connref in self.connections.itervalues():
conn = connref() conn = connref()
if conn is not None and conn.ready: if conn is not None and conn.ready:
conn.send_websocket_ping() conn.send_websocket_message('ping')
class ReloadServer(Thread): class ReloadServer(Thread):