Losant Connection Status Check at Edge Agent

Hello,

I would like to improve a fault tolerance of my edge gateways by running an additional software watchdog inside of Edge Agent. In order to do so, I plan to build a latch by setting a variable like the following:
(1) for Device: Connect;
(0) for Device: Disconnect;
(0) for Device: Startup.

If the agent doesn’t get connected to Losant after 10 Minutes from Disconnect or Startup events, the edge host OS will get a command to reboot the gateway.

Something like that:

My Question is: Is there a way to check Losant conneciton status continuosly from the container? Like every minute with a timer? I want to avoid a situation, when the value was not set for some reason during the connection and the gateway reboots without a reason.

Suggestions to improve the logic are also welcome.

Thank you

Hi Alexander,

I have a couple of suggestions for you, let’s jump in!

I first want to point out that your Delay Nodes would time out your workflow, as mine did for only 60 seconds:

Since this limit exists, I would recommend a Timer, and possibly utilizing Workflow Storage to determine the last timeout.

The connection status to Losant is displayed in the Debug Log like so:

If you would like to check the connection status from the container, you would likely want to add it as an environment variable on container startup.

I believe that if you were to create a workflow and utilize a Timer Node in conjunction with the Device: Disconnect Node, then make use of Workflow Storage and a connected environment variable, you would be quite useful for building this fault tolerance workflow!

Please let me know if you have any further questions :smile:

Thanks!
Julia

1 Like

Hi Julia, thank you for help. I re-built my logic using isConnectedToLosant boolean and a timer, checking the status every minute. The decision on a reboot is made based on a time difference between last connected/disconnected. The only two questions I wonder about are 1)if there is a way to catch a moment when a newer workflow version is applied to the agent 2) can I reboot the agent with one of the nodes?

Hi @Alexander_Kondrov,

There is not currently a workflow node that is able to reboot the agent. When your use case requires a reboot, would the device be connected or disconnected?

I am interpreting “catch a moment when a newer workflow version is applied” to mean you are hoping to trigger off of this event. Currently, there is not a way to “store” the exact time a workflow was pushed to your device. This value is currently only accessible as a timestamp on your device page, though you could do some handling on the device side. If I have interpreted your question correctly, I was curious if you could explain your use case for this value :smile:

Thanks!
Julia