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 // Send message every 30 s
//setInterval(() => { // Because Heroku terminate connection in 55 s inactivity
// wss.clients.forEach((client) => { // https://devcenter.heroku.com/articles/error-codes#h15-idle-connection
// client.send(new Date().toTimeString()); setInterval( () => {
// }); var data = {
//}, 1000); ctrl: 'idle',
time: new Date().toTimeString()
}
wss.clients.forEach( (client) => {
client.send( data );
});
}, 30000); // 30 s