MQTT can't get the full data for subscribed topics

Hi, 

I'm using nRF9160, NCS2.2.0, and using serial_lte_modem sample.

Recently, I have developed a program for MQTT, and I encountered the following phenomenon.

1. nRF9160 subscribed to a topic.

2. I send some data to the topic.

3. When the size of this data exceeds 670 Bytes, nRF9160 only read a part of this data, and the rest of this data is unreadable.

I debug the code to locate the following problem:

In file slm_at_mqtt.c, path: ${NCS_ROOT}/nrf/applications/serial_lte_modem/src/mqtt_c/slm_at_mqtt.c:92

do {
		ret = mqtt_read_publish_payload(c, rsp_buf, sizeof(rsp_buf));
		if (ret > 0) {
			data_send(rsp_buf, ret);
			size_read += ret;
		}
	} while (ret >= 0 && size_read < evt->param.publish.message.payload.len);

Firstly, I calll mqtt_read_publish_payload() to get this data, the 'ret' return 570, it is means i get 570Bytes from MQTT, but I send size is 670 Bytes.

Then, continue reading data, but the 'ret' return a negative error code(-11).

Finally, the MQTT disconnect.

How do I get the rest of this data?

Best Regards,

Yang Hu

Parents Reply
  • Hi Hakon,

    I was able to reproduce the problem on the 9160dk using the following steps.Maybe you can reproduce the problem on 9160dk

    1. NCS version: V2.2.0

    2. nRF9160 modem version: V1.3.2

    3. Board: nrf9160dk_nrf9160_ns

    4. Application: serial lte modem

    1. AT
    2. AT%XSYSTEMMODE=0,1,0,0
    3. AT+CEREG=5
    4. AT+CSCON=1
    5. AT+CFUN=1
    6. AT+CFUN?
    7. wait +CEREG: 1
    8. AT#XMQTTCON=1,"MyMQTT-Client-ID","","","91.121.93.94",1883 /* Using the server in the nrf9160/mqtt_simple */
    9. AT#XMQTTSUB="/cgw/cmd-request/cgw/351358811068466/cmd-request",1
    10 Then publish data to the MQTT topic

Children
Related