Periodically send ping to WebSocket

This may help keep the WebSocket alive in some firewall situations.
This commit is contained in:
Max Goodhart
2020-07-06 21:07:59 -07:00
parent 003db47b9c
commit 2c7f4516ab

View File

@@ -57,8 +57,13 @@ function initApp({
ws.binaryType = 'arraybuffer'
const pingInterval = setInterval(() => {
ws.ping()
}, 20 * 1000)
ws.on('close', () => {
sockets.delete(ws)
clearInterval(pingInterval)
})
ws.on('message', (rawData) => {