diff --git a/lib/editor/tunnel.js b/lib/editor/tunnel.js index 6eb0d57..112aba3 100644 --- a/lib/editor/tunnel.js +++ b/lib/editor/tunnel.js @@ -248,6 +248,13 @@ class EditorTunnel { }) } }) + clearInterval(this.pingInterval) + this.pingInterval = setInterval(() => { + debug('Sending WS editor tunnel ping') + try { + socket.ping() + } catch (err) { } + }, 40000) } socket.on('close', async (code, reason) => { if (Buffer.isBuffer(reason)) { @@ -257,6 +264,7 @@ class EditorTunnel { info(`Editor tunnel closed code=${code} reason=${reason}`) socket.removeAllListeners() this.socket = null + clearInterval(this.pingInterval) clearTimeout(this.reconnectTimeout) // Pre 1.12, FF returned '1008/No Tunnel' - but 1008 was also used // for other scenarios, so we have to check both code and reason text. @@ -310,6 +318,7 @@ class EditorTunnel { // ensure any active timers are stopped clearInterval(this.connectionReadyInterval) clearTimeout(this.reconnectTimeout) + clearInterval(this.pingInterval) } async waitForConnection () {