Edge Agent does not trigger "Device:Startup" after a system reboot

The Edge Agent seems to work fine with Device:Connection when I drop and bring up network interface. but It does not get triggered when the system is first powered up or at reboot. Debug does not seem to pick any traffic. So, I tried to use a Device:StartUp instead but same issue. I gave it a delay of 60 seconds to see if there was a problem with the timing at boot time but still no functionality is seen. Can someone please help me, I am very new to Losant and the concept of workflows.

1 Like

@Leonardo_Roman,

Welcome to the Losant Forums! Happy to have you here.

In order to understand your particular problem, our engineers are working to reproduce the issue here internally.

We have confirmed that the Device:Startup node is being invoked correctly, but it is not sending debug messages.

I will follow up as soon as I have additional feedback to provide.

Thanks,
@Aidan_Zebertavage

Hey @Leonardo_Roman,

Just following up from yesterday - our engineers were able to recreate your issue on our side and we have identified that a fix is necessary and will be a part of our next release.

The Edge Agent is waiting for all Device: Startup workflows to complete before connecting to the MQTT broker - and since you need to be connected to the broker to receive debug messages, you will not see these debug messages - this is a bug on our end and we will incorporate the fix in the next release.

I will follow up directly when this fix is in. Thanks very much for bringing it to our attention.

Let us know if you have any other questions as you continue on your Losant journey!

Thanks,
@Aidan_Zebertavage

Hello!

It would also be nice if we could trigger when flow is deployed.

Thanks

@Kelvin_Andrade1,

Thanks for the additional input. I’ll incorporate your request into a new Feature Ticket and follow up if its released.

Thanks,
@Aidan_Zebertavage

1 Like

I have the same issue as @Leonardo_Roman but with the device not publishing its state when triggered by the Device Startup node.

The below screenshot is the log for a device that is running a workflow that should publish some attributes when triggered by the Device Startup node. When I issue the reboot command, the device power-cycles and the Edge Agent disconnects as expected, but doesn’t publish anything after rebooting and reconnecting.

This screenshot below is the log for the same device running the same workflow as above, but I issued the “docker stop” then “docker run” commands to simulate the “device startup” and did not actually power-cycle the device. This time the device published its attributes after reconnecting, as I expected would happen for both scenarios.

So why isn’t the Device Startup trigger working on an actual device startup/reboot?

Do you happen to have queueOfflineMessages set to false? Device: Startup triggers fire before the MQTT connection has been established. With that disabled, messages will not be queued for when the connection is established.

No, I’m using the defaults.

I’m having some difficulty reproducing the issue. I’ve tried:

  1. Docker restart
  2. System reboot
  3. Hard power cycle

In all cases I do receive the state message after the device successfully connects. Follow up questions:

  1. Is there any logic in the workflow that will cause it skip the state report (conditional, etc)?
  2. Is it possible the workflow is erroring on one of the nodes above the state node?
  3. Can you reduce the workflow to just a trigger and a state node to attempt to eliminate all other variables?

I added a new edge workflow with only 2 nodes, a Device Startup trigger node and a Device State publishing node. Long story short, the Startup trigger does not fire when the device is powered on and the Edge Agent’s container runs. The attached screenshot shows two power-on cycles without anything published to the cloud after the Edge Agent connects.

On the other hand, manually stopping then re-starting the Edge Agent’s container does cause the Device Startup trigger to execute and publish to the cloud.

Any ideas? Does the Edge Agent need to save some state information before powering down so that the Startup node will trigger at the next power-on?

@Paul_Muschick,

Thanks for more information!

Because you mentioned this:

On the other hand, manually stopping then re-starting the Edge Agent’s container does cause the Device Startup trigger to execute and publish to the cloud.

It looks like this may be something with persistent storage with the Agent.

For example, here is the Docker command to start the Edge Agent with a config file.

docker run -d --restart always --name docs-agent \
  -v /var/lib/losant-edge-agent/data:/data \
  -v /var/lib/losant-edge-agent/config.toml:/etc/losant/losant-edge-agent-config.toml \
  losant/edge-agent

It’s this line that’s the important one:

 -v /var/lib/losant-edge-agent/data:/data

This mounts the local folder as a Docker volume. This setting is required for the persistent storage of the Agent. It maps the folder /var/lib/losant-edge-agent/data (outside the container) to /data (inside the container)

Would you happen to have this configured?

Yes, it’s configured. The command we use is…

/usr/bin/docker run -d --rm --name losant-edge-agent
-v /mnt/userflash/losant-edge-agent/config.toml:/etc/losant/losant-edge-agent-config.toml
-v /var/lib/losant-edge-agent/data:/data
-v /mnt/userflash/losant-edge-agent/persisted:/flash
-v /var/log:/log
-p 49446:49446/udp $LOSANT_EDGE_AGENT_IMAGE

Looking at this further, I see what the problem might be. The Edge Agent’s /data folder should be mounted to /mnt/userflash/losant-edge-agent/persisted, as /var/lib/losant-edge-agent/data is volatile.

Thanks for pointing me in this direction, Taron.

@Paul_Muschick,

No problem! We are here to help :slight_smile: