Hi guys,
Our product requires us to know if a device was online or offline in a time period, I’ve seen that there are vital events, Cloud API | Reference Documentation | Particle but I don’t think it’s a scalable solution.
My idea is to know asap if a device is online or not then we might want to create an integration with BigQuery that saves the spark/status online and offline events so that we can query those later.
Does anyone know how often spark/status events are sent from the device os? Or is it something else that we should use?
Hi @robikovacs ,
The frequency at which online/offline status indicator is dependent on a number of factors. Which Particle SKU or SKUs are you interested in attempting to build on?
For graceful shutdowns, such as sleep or OTAs, Particle devices may send an event to indicate they will be going offline. However, I imagine you are more interested in the cases where devices may not gracefully shut down or lose connectivity. More on this below:
Particle’s wifi SKUs are generally more responsive to online/offline events. I don’t have the exact number off the top of my head, but I believe it’s around 30s-60s before our wi-fi devices flag as offline.
For cellular devices, it’s a bit longer of a timeout. Because our cellular devices are exclusively UDP and we leverage high NAT timeouts to decrease bandwidth, there’s increased idle time before verifying online state. Particle devices check in every 23 minutes with a keepAlive ping to prevent the cellular carrier timeout from occurring and putting the device into a half-duplex situation. We also allow devices to miss one online ping and will flag it offline after the second missed check-in – meaning Particle’s online status indicator for cellular devicse may not indicate the device is actually offline for up to 46 minutes.
If you find need to validate this more frequently, there are some workaround you can use, such as requesting a variable from the device to validate its online state. Do be warned that requesting functions or variables in such a manner will increase data operations consumption.
Thank you, @mstanley for the quick response!
We plan to use cellular devices, Boron. So you are saying that in the worst case every 46 minutes there will be a spark/online event sent to Particle Cloud? That’s enough for us to flag the device as online for that particular hour, that would work. We want to keep data operations consumption at a minimum.
1 Like
In the worst case, there will be a spark/offline sent emitted by the cloud up to 46 minutes after the device last communicated with the cloud. spark/online events are immediate, following a device’s first communication with the cloud if it was previously in the offline state.