Added interval function to avoid disconnection

This commit is contained in:
Eunchong Kim 2021-08-08 14:11:26 +09:00
parent 6a9305f7e9
commit b5bd28fd45

View File

@ -40,9 +40,15 @@ wss.on('connection', (ws) => {
});
// Broadcast updates
//setInterval(() => {
// wss.clients.forEach((client) => {
// client.send(new Date().toTimeString());
// });
//}, 1000);
// Send message every 30 s
// Because Heroku terminate connection in 55 s inactivity
// https://devcenter.heroku.com/articles/error-codes#h15-idle-connection
setInterval( () => {
var data = {
ctrl: 'idle',
time: new Date().toTimeString()
}
wss.clients.forEach( (client) => {
client.send( data );
});
}, 30000); // 30 s