Frequent MQTT Disconnects

Hello, I have a device that is connecting and reconnecting every few seconds. Below is a screenshot of what Losant is showing.

Hey @Steve_Ermish,

It looks like your device is establishing a new connection over and over again. Could you by chance be using the same device id for two devices?

When a device ID is reused, Device A will connect, then device B will connect, kicking off Device A. Then Device A will connect, and kick Device B off. This loop will keep happening.

Thank you,
Heath

Hi @Heath,

We are not reusing the IDs, each device currently uses its own ID and Access Keys to connect to Losant. Most of the other devices are working correctly but we have seen this frequent connection/disconnection problem on a few of our devices.

What could be other reasons for this?

The latest error in the log you posted says “Keepalive timeout”, and the interval of
the disconnects seems to hint at a problem with PING requests and responses,
but it could be any number of reasons.
A wireshark session would probably let you diagnose the problem.
Not knowing which type of device and it’s MQTT implementation, there is not much
to diagnose here. If you question it’s MQTT implementation, you would run it through
a MQTT protocol tester (google it).

I have to agree with @Heath here: The best explanation, given the messages displayed in your connection log and the consistent rhythm of the disconnections, is that the device ID is being used as the client ID in more than one connection to Losant’s MQTT broker. If you can provide us with a device ID for one of the devices where you are seeing this behavior, we can dig a little deeper.

Hi @Dylan_Schuster I think the duplicate client is not a possibility in terms of the flow we are using but I can check on that and confirm.

I will PM you one of the device ids.

Thank you

@Dylan_Schuster Whew what a delay in response from our side. Suroor is not longer with us and we are picking up the pieces. This issue still seems to be plaguing us.

this is a test device that was recently added to our device pool. I have checked the device ID and the MAC address in our device list and I know that this device is unique.
Since this original post have you seen further issues like this and if so is there a resolution? setting changes or ???

A Keepalive Timeout, as depicted in your screenshot, is a completely different issue than the one that we were originally tackling in this post.

From our documentation:

  • Keepalive Timeout: The device was disconnected because it did not satisfy the keepalive requirements of the connection - there was no traffic over the connection for 1.5 times the keepalive value requested by the client. This is often by default 90 seconds.

How is your hardware connecting to Losant’s MQTT broker? Is it an Edge Compute device using Losant’s Gateway Edge Agent? Are you using one of Losant’s client libraries? A different client library?

Most MQTT clients, including ours, automatically handle the keepalive heartbeat. That, combined with how inconsistent the time the device is remaining connected seems to be based on your screenshot (sometimes a few minutes, sometimes several hours), makes me wonder if an intermittent internet connection is the cause.

Thanks @Dylan_Schuster Based on the Keepalive Timeout note you posted this may be normal for many of the disconnections. We are also analysing some disconnects that are not part of the Keepalive Timeout where our devices are disconnecting for long periods of time Hours/Days. I will start with looking at your suggestions above.

Thanks