mdopp / simple-sonoff-server

Emulates the original sonoff-cloud-servers within your local network.
BSD 2-Clause "Simplified" License
144 stars 47 forks source link

device.messages may contain stale messages #20

Open PKGeorgiev opened 6 years ago

PKGeorgiev commented 6 years ago

In situations where a registered sonoff device becomes offline or it was unable to acknowledge a packet due to intermittent wifi drop, the message will remain in device.messages forever.

Since message.sequence is a timestamp, a periodic timer could be implemented to clear stale messages (older than X minutes for example).

I have two more questions:

  1. What happens to devices that were not alive more than X minutes? Are they removed from devices list?
  2. Shouldn't the API server return an error code when you try to control a device that is not currently active?
mdopp commented 6 years ago

Hi, enhancements are welcome!

About the "remove when inactive" => the devices do not send keep-alives, hence we would have to implement the other way around and the server has to send keep-alive-checks. And yes, it should return an error, when the device is not active! good point

PKGeorgiev commented 6 years ago

Are you going to realize the stale message removal strategy using a timer?