This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

MQTT messages received multiple times on QoS 1 subscription

I am using the SLM app from the 1.9.1 SDK.

I connect to my MQTT broker using TLS offloaded on the modem.

I subscribe to a topic using QoS = 1

Then if a message is published to the same topic using QoS = 1 then the nrf9160 reports the message received over and over again every few seconds.

If I instead subscribe to the topic using QoS = 0 then I will only get the messages (published at QoS = 1) one time.

Is this the intended behavior? I feel unsure that I am actually operating under QoS = 1 conditions when the subscription is set to QoS = 0.

  • Hello, have confirmed that this was a bug. A bug fix has been registered https://github.com/nrfconnect/sdk-nrf/pull/7363 

    Kind regards,
    Øyvind

  • In order to fix the issue in the nRF Connect SDK tag 1.9.1 - please add the following to the beginning of handle_mqtt_publish_evt() in nrf\applications\serial_lte_modem\src\mqtt_c\slm_at_mqtt.c

    const struct mqtt_publish_param *p = &evt->param.publish;
    LOG_INF("MQTT PUBLISH result=%d len=%d",
    		evt->result, p->message.payload.len);
    	
    ret = publish_get_payload(c, evt->param.publish.message.payload.len);
    if (ret < 0) {
    	return ret;
    }
    
    if (p->message.topic.qos == MQTT_QOS_1_AT_LEAST_ONCE) {
    	const struct mqtt_puback_param ack = {
    	.message_id = p->message_id
    	};
    	/* Send acknowledgment. */
    	mqtt_publish_qos1_ack(&client, &ack);
    }

Related