MQTT subscription messages not being received | Telit Cinterion IoT Developer Community
November 17, 2021 - 11:29pm, 1736 views
Recently I have noticed that the MQTT is not receiving the messages on the topic it subscribes to.
I am not sure if it is because I upgraded the FW or something.
To prove I am not doing anything wrong, I am using the example in SDK/examples/mqtt/mqtt.c file.
This example uses the qapi to connect and publish/subscribe to topics in MQTT.
I did several tests, and the example works for publishing, and I can see with other client that the data is being received.
Doing some investigation, I've noticed that on these steps:
1) ret = qapi_Net_MQTT_Set_Connect_Callback(_mqtt_handle, dam_mqtt_connect_callback);
2) qapi_Net_MQTT_Set_Subscribe_Callback(_mqtt_handle, dam_mqtt_subscribe_callback);
3) qapi_Net_MQTT_Set_Publish_Callback(_mqtt_handle, dam_mqtt_publish_callback);
4) qapi_Net_MQTT_Set_Message_Callback(_mqtt_handle, dam_mqtt_message_callback);
Over these callback steps (1), (2), (3), and (4), all of them have printfs to inform that the code has reached that point or not.
Only (1) and (3) is being reached.
I am not sure why it is not working.
On Mosquitto MQTT side, I can see that the module is connecting, subscribed to the topic, and it is publishing on the another topic. But the callbacks are not called. And if I publish from a different client on the topic the module is subscribed to, nothing happens.
Logs of the Mosquitto:
1637192161: mosquitto version 2.0.10 starting
1637192161: Config loaded from /etc/mosquitto/conf.d/default.conf.
1637192161: Opening ipv4 listen socket on port 1883.
1637192161: mosquitto version 2.0.10 running
1637192206: New connection from ***.***.***5:1234 on port 1883.
1637192206: New client connected from ***.***.***:1234 as mqtt_client1 (p2, c1, k60, u'mqtt_user1').
1637192206: Will message specified (37 bytes) (r0, q0).
1637192206: mqttwill
1637192206: Sending CONNACK to mqtt_client1 (0, 0)
1637192206: Received SUBSCRIBE from mqtt_client1
1637192206: mqtttest (QoS 0)
1637192206: mqtt_client1 0 mqtttest
1637192206: Sending SUBACK to mqtt_client1
1637192216: Received PUBLISH from mqtt_client1 (d0, q2, r0, m24475, 'counter', ... (17 bytes))
1637192216: Sending PUBREC to mqtt_client1 (m24475, rc0)
1637192217: Received PUBREL from mqtt_client1 (Mid: 24475)
1637192217: Sending PUBCOMP to mqtt_client1 (m24475)
1637192260: Received PUBLISH from mqtt_client1 (d0, q2, r0, m15846, 'counter', ... (17 bytes))
1637192260: Sending PUBREC to mqtt_client1 (m15846, rc0)
1637192260: Received PUBLISH from mqtt_client1 (d1, q2, r0, m15846, 'counter', ... (17 bytes))
1637192260: Sending PUBREC to mqtt_client1 (m15846, rc0)
1637192260: Received PUBLISH from mqtt_client1 (d0, q2, r0, m9052, 'counter', ... (17 bytes))
1637192260: Sending PUBREC to mqtt_client1 (m9052, rc0)
But again, the code is the same as in the SDK/examples/mqtt folder.
=========================
Details of the module:
EXS82-W A2.4
ati1
Cinterion
EXS82-W
REVISION 01.100
A-REVISION 01.000.14
OK
Hello,
These functions for callbacks registration can return a response - QAPI_OK on success or < 0 on failure. The example does not check this. I'd modify it to see if the callbacks registration was successful.
Please see 80-p8101-35_a_mdm9206_threadx_qapi_usage_guide_(typical_use_cases).pdf in SDK for some examples. Please check the SDK version in the README file.
BR,
Bartłomiej
I simplified it here to not pollute with much information.
But yes, I am checking all function returns for errors and checking the logs.
No errors are reported during the registration of the callbacks.
About the PDF file you mentioned, I've also checked it through on the MQTT section, and I do not see any differences from what I am doing.
So far, I do not know what is the core issue.
Checked README.txt file:
Gemalto EXS82 Embedded Processing SDK
Version 0.1.3
This version seems to be quite old. The current official version is 0.2.005. In such case I'd recommend you to contact your technical sales and as for the latest SDK.
BR,
Bartłomiej
I just got SDK 0.2.002 now.
Will check and I let you know.
Follow-up:
After updating to SDK 0.2.002, the subscription is working fine now.
Thank you for the help BARTŁOMIEJ.