This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

MQTT subscriber keepalive timeouts

I'm using an nrf52dk (pca10040) to develop an mqtt subscriber application.

I'm using the IoT softdevice, with the IoT 0.9.0 sdk example for subscriber as a starting point, with armgcc and eclipse.

Raspberry pi 1b+ running jessie with radvd & 6lowpan module to act as a gateway / border router

After establishing a 6lowpan link, I am able to connect to my broker (RabbitMQ with MQTT plugin) on the cloud directy using the example code for mqtt subscriber, and I can subscribe to the 'led/state' topic.

When I publish messages to the topic from other clients, the led on the nrf52dk reflects the state published. This is working as expected.

Problem:

I have noticed that eventually the nrf52832 will become disconnected from the broker due to keepalive timout. There doesn't seem to be any direct cause for this, Im just noticing that it eventually happens and disconnects clients after a period of time, usually within 10 minutes.

Using tcpdump on my broker, I'm able to observe keepalive exchanges taking place every ~60s when things are operating normally. However, eventually one will be missed and the broker will disconnect the session. Once this happens, I merely need to press button 0 to reconnect, and then button 1 to subscribe, and all is well again for a while...

The raspi ble router and the nrf52dk are about 2 feet from eachother and stationary during these tests, so I assume the 6lowpanconnection is reliable.

This same behavior happens when I use the mosquitto broker instead.

Question:

Is this something normal to expect to happen or are there known issues with keepalive timeout? Any recommendations to determine why the keepalive ping is missed? What recommendations does anyone have to work around this and create a more reliable mqtt connection?

Related