Devices does not connect


We are experiencing some “Unknown Connection Status” for ALL our devices, Please see attached picture for reference.

Thanks in advance

@CHAIMAA_DRIOUECH you will see this status in two different scenarios:

  1. Immediately after a device is created in Losant and before its first connection to our MQTT broker (or before its connection status is set manually through our REST API).
  2. If the device has not connected in a very long time - so long that your organization’s data TTL would have expired any previous connection status.

We recently made a change that would make the second case no longer happen, but it would still require a connection event after the TTL expiration to persist that connection status long-term.

Are you asking because your devices are connecting to our MQTT broker and you are not seeing that status change?

Yes all devices are connected to the MQTT Broker, and I don’t know what this “Unknown Connection Status” exactly means ? I looked on my dashboard and it looks like the devices are connected but still some of them not reporting any data, my Nod-RED program also shows me that the MQTT node is connected to the MQTT broker on Losant.

Hope I can get your help to understand what is happening.


Can you provide me an application ID and a device ID of a device that is currently connected to the broker but is displaying “Unknown connection status” in the interface?

Sure, the application ID : 5c8289d92875110008983765 and the devices that are not reporting data even though they are shown being connected to the broker are : 5f36d27a12492800064d7507 and 5f36d27abfeec6000669721a.

Thanks again!

Well, “devices that are not reporting data even though they are shown being connected to the broker” is a much different problem than the one you originally stated, which was that “We are experiencing some “Unknown Connection Status” for ALL our devices”.

The device IDs you referenced are peripheral devices, which in Losant terms represents a device that cannot connect to the Internet itself and thus relies on a separate gateway device to report state data on its behalf.

I understand the source of confusion, because on the device list page, we list peripherals as “Device does not connect” (not “Unknown Connection Status”). This is because, technically, the device itself does not connect to the Losant MQTT broker, and to state that they are connected in the filterable device list could be misleading.

By contrast, on the device detail page of a peripheral, we do display the peripheral’s gateway’s connection status, and there you will see that your gateway is indeed connected.

As to why your peripherals are failing to report state even though their gateway is connected, that would require some additional information for me to help with. The problem likely exists in the code you have running on the gateway device. If you can post code samples (make sure to scrub sensitive information such as access keys and secrets before doing so), I may be able to help with that.

Sure, here are screenshots of my MQTT node settings on my Node-RED program on the gateway:

I took a look in your account and kept an eye on your application live log, and during that time, I did see state reports coming in for peripheral devices other than the two you referenced in this thread. Those peripherals that reported state are tied to the same gateway device as the peripheral IDs you gave me earlier. See attached.

(Device 6091ac86e8e2060006ffe57b is the same gateway, listed by ID instead of name, as is applied to peripherals 5f36d27a12492800064d7507 and 5f36d27abfeec6000669721a.)

This leads me to believe that the error is somewhere in your Node-RED flow and not in the MQTT integration, as we’ve confirmed the gateway is connecting and reporting state for at least some devices.

The screenshots you provided, then, will not lead us to the answer here. I would suggest some additional local debugging in your Node-RED flow; are there any error logs or debug messages you can check?

Here are some additional screenshots that may point you in the right direction. It looks like all of your state reports contain either attributes that are not defined on their respective devices, or the shape of the values is incorrect and thus data is not recorded. It’s likely somewhere in your Node-RED flow you are not constructing the state report JSON object correctly, and that is why you are not seeing state data getting logged against those devices.

Yes I agree all sensors are connected to the same gateway, there are exactly 6 sensors, structured and created in the same way on my Node-RED program, connected using the same MQTT broker, 4 of them are perfectly reporting data including the two ones 44495 and 44398 on your last screenshots showing not defined attribute, it means that the showing “error” really isn’t the explanation of what is going on with the two ones that are not reporting at all which are 19040339 and 19040259.

@CHAIMAA_DRIOUECH Without having your full Node-RED flows in hand, I don’t think there’s much else I can do to help debug this. The provided screenshots do not point to any obvious error, especially given that we’ve established that the MQTT connection is working. You are welcome to post the flows here (scrub credentials) or send them to me in a private message and I can take a look.

Sure, You just need the part where I send the data through MQTT right ?

It’s hard to say without being familiar with what you have so far; I would guess I would need the whole flow so I could see how you are defining the MQTT topics to publish to and how you are constructing the objects you are publishing on the state topic.

OK let me gather all information needed and send it back to you, Thanks again for your help!