Added interval function to avoid disconnection
This commit is contained in:
parent
6a9305f7e9
commit
b5bd28fd45
18
ws_server.js
18
ws_server.js
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user