# Losant Connection Status Check at Edge Agent

**URL:** https://forums.losant.com/t/losant-connection-status-check-at-edge-agent/2529
**Category:** Help
**Tags:** edge
**Created:** [January 13, 2020, 3:02pm UTC](https://forums.losant.com/t/losant-connection-status-check-at-edge-agent/2529 "2020-01-13T15:02:08Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Alexander\_Kondrov](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/alexander_kondrov/32/1392_2.png) [@Alexander\_Kondrov](https://forums.losant.com/u/Alexander_Kondrov)
#### Post date: [January 13, 2020, 3:02pm UTC](https://forums.losant.com/t/losant-connection-status-check-at-edge-agent/2529/1 "2020-01-13T15:02:08Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/4/4b9ba521fe56edf56b0b12b025525feaf1e5af44.png)

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

---

<div class="post-metadata">

### Author: ![JuliaKempf](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/juliakempf/32/2446_2.png) [@JuliaKempf](https://forums.losant.com/u/JuliaKempf)
#### Post date: [January 13, 2020, 4:43pm UTC](https://forums.losant.com/t/losant-connection-status-check-at-edge-agent/2529/3 "2020-01-13T16:43:05Z")

</div>

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:

 ![Screen Shot 2020-01-13 at 10.51.30 AM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/c/c675ee5da93753da2d2cb9ef7ee50b0c2e169837.png)

Since this limit exists, I would recommend a Timer, and possibly utilizing [Workflow Storage](https://docs.losant.com/workflows/data/get-value/) to determine the last timeout.

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

 ![Screen Shot 2020-01-13 at 11.23.56 AM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/2/2667ab029dcb3879abac62dd8c01011429f19e2f.png)

If you would like to check the connection status from the container, you would likely want to add it as an [environment variable](https://docs.losant.com/edge-compute/edge-agent-usage/#agent-configuration-options) on [container startup](https://docs.losant.com/edge-compute/edge-agent-usage/#running-with-environment-config).

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 😄

Thanks!  
Julia

---

<div class="post-metadata">

### Author: ![Alexander\_Kondrov](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/alexander_kondrov/32/1392_2.png) [@Alexander\_Kondrov](https://forums.losant.com/u/Alexander_Kondrov)
#### Post date: [January 14, 2020, 9:11am UTC](https://forums.losant.com/t/losant-connection-status-check-at-edge-agent/2529/5 "2020-01-14T09:11:18Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![JuliaKempf](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/juliakempf/32/2446_2.png) [@JuliaKempf](https://forums.losant.com/u/JuliaKempf)
#### Post date: [January 16, 2020, 8:40pm UTC](https://forums.losant.com/t/losant-connection-status-check-at-edge-agent/2529/7 "2020-01-16T20:40:31Z")

</div>

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 😄

Thanks!  
Julia

---

<div class="post-metadata">

### Author: ![Alexander\_Kondrov](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/alexander_kondrov/32/1392_2.png) [@Alexander\_Kondrov](https://forums.losant.com/u/Alexander_Kondrov)
#### Post date: [January 23, 2020, 10:02am UTC](https://forums.losant.com/t/losant-connection-status-check-at-edge-agent/2529/9 "2020-01-23T10:02:49Z")

</div>

Hi Julia,

My request was related to a desire of a better control of processes happening on the agent. Such as I am not fully aware if stored variables reset every time and to which value when 1) a newer workflow version is published 2) Agent reboots 3) Agent reboots after being hanged

Could you help me to understand it please?

---

<div class="post-metadata">

### Author: ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)
#### Post date: [January 23, 2020, 12:05pm UTC](https://forums.losant.com/t/losant-connection-status-check-at-edge-agent/2529/11 "2020-01-23T12:05:30Z")

</div>

@Alexander_Kondrov,

In terms of [Workflow Storage](https://docs.losant.com/workflows/data/get-value/), those are persisted on disk. So, given that you have the [store](https://docs.losant.com/edge-compute/edge-agent-usage/#configuration-file-example) configured on your Edge Agent, the values shouldn’t reset upon new workflows or agent reboots.

Also, as an added note: Losant does expose [flowVersion](https://docs.losant.com/workflows/edge-workflows/#payload) on the payload; it is the name of the current version of the Losant Workflow that is running. You can use that variable in the [On Change Node](https://docs.losant.com/workflows/logic/on-change/) to easily perform actions when a new version occurs.

Also, touching on your Reboot Node suggestion. I’m wondering about the need to reboot the agent from within a workflow. I am curious about one comment you made. Could you elaborate what you mean here by “hang”:

> [@Alexander\_Kondrov](#):
>
> 1. Agent reboots after being hanged

---

<div class="post-metadata">

### Author: ![Alexander\_Kondrov](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/alexander_kondrov/32/1392_2.png) [@Alexander\_Kondrov](https://forums.losant.com/u/Alexander_Kondrov)
#### Post date: [January 23, 2020, 2:42pm UTC](https://forums.losant.com/t/losant-connection-status-check-at-edge-agent/2529/12 "2020-01-23T14:42:26Z")

</div>

Hi Taron,

Thank you for as always prompt reply. I am not saying that Losant Agent has a tendency to hang, at the same time I do allow a chance for it to exist.

---

<div class="post-metadata">

### Author: ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)
#### Post date: [January 23, 2020, 4:21pm UTC](https://forums.losant.com/t/losant-connection-status-check-at-edge-agent/2529/13 "2020-01-23T16:21:39Z")

</div>

@Alexander_Kondrov

Ah got it! I wanted to make sure that there wasn’t a bug there. However, yes there are a number of items, like saving workflow storage to disk, that happens on the shutdown of the agent.

Please keep the good questions coming!
