interactiveinstitute / energy-intelligence

Visualisation touch screen app for SP
1 stars 0 forks source link

Commands from remote.js get missed if they fall right after an EventSource timeout #1

Closed sander closed 11 years ago

sander commented 11 years ago

In html/js/remote.js we keep an EventSource connection to remote.js to listen to commands. This connection has a 50s timeout as a heartbeat mechanism, i.e. remote.js just assumes disconnection if there’s no reconnection after the 50s.

After this timeout, it takes EventSource in Chrome about 3s to reconnect. Currently, any commands sent during those 3s get ignored.

This could be fixed by one of these options.

  1. Have remote.js remember every command for say 10s. Any new connections made during those 10s get the stored commands. However, we need to prevent a restart command from causing an infinite loop.
  2. Have remote.js announce a timeout with an ID, allowing the client to send a GET request to /keepalive?id=ID in time to keep the connection alive.

Workaround: send each command twice with a 5s delay to make sure the client has received it.

sander commented 11 years ago

Another workaround: have the Command API return the number of clients that received the command. If zero, the sender can send it again.