Offline event at mDash endpoint

I was looking at the docs for catching notifications. It works great when a device goes online/updates, but it never fires the offline event.

The only way I have received an “offline” message, is when I reset, so before coming online y fires the “offline” event

The docs states: “When a device disconnects, this usually happens in a non-clean way (e.g. device power-off). mDash sends TCP keep-alive every 20 seconds, and closes the connection after 3 failed keep-alives. When a connection is closed, mDash sends DEVICE_ID message to the db/offline topic. Disconnected device automatically goes to step 1 (reconnects)”

But this offline event is never received. Is this normal? We are using the /api/v2/notify endpoint

https://mdash.net/docs/#catching-notifications

1 Like

@fbritop I spent some time looking into this myself. In my testing, the offline notification mechanism worked every time for me. I tried both powering off a device and using the “disconnect, force reconnect” button on the mDash device console. In both cases when the device went offline on the mDash console, a WebSocket notification was made at the same time.

Having said that, it looks like there is a genuine problem with the mDash offline detection mechanism. I took an online device and removed power then measured the time it took for mDash to detect the offline state. For three different attempts, the average time was 16 minutes. Ouch.

Online detection, by contrast, was immediate.

@Cesanta:
Can you investigate and advise how this issue could be fixed?

Thanks!
-AD

@fbritop @Autodog

We have confirmed an issue with offline detection.
A change has been pushed to mdash that aggressively pings active connections and times them out after ~45 seconds if they do not respond.
Please confirm that offline events are indeed fired.

With some limited testing seems to be working as expected. Thanks!