Publishing to Anycloud MQTT Clients Yields Broker Disconnection

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
MattTreiber
Level 3
Level 3
25 sign-ins 10 replies posted 10 sign-ins

Using the https://github.com/Infineon/mtb-example-wifi-mqtt-client demo project with a CY8CKIT-062S2-43012, after publishing to the client, the client stops sending a PINGREQ to the MQTT broker and the broker will send a disconnect when the client exceeds the KEEPALIVE timeout.

The expected behavior would be to keep the connection with the broker alive regardless of how often the client is published to or what is being published.

I am migrating a project to v4.0.0 of the Anycloud MQTT Client (this started before v5.0.0 was release) and I first noticed this behavior when I added a simple hardware timer that had nothing to do with MQTT. In that investigation I found that the FreeRTOS timer for the KEEPALIVE ping request fails, the client fails to ping, and the MQTT broker sends a disconnect message when the timeout is exceeded.

To repeat the issue:

This is on version 4.0.0 of the demo code, using version 2.4 of ModusToolbox, and a un-secure connection to a Mosquitto broker on my network running on an Ubuntu v20 box. The broker is set up with both secure and un-secure connections and I have noticed the failure to send a PINGREQ with both. An un-secure connection allows easy verification via Wireshark.

  • Clone and checkout v4.0.0 of https://github.com/Infineon/mtb-example-wifi-mqtt-client
  • Run “make modlibs” and switch the BSP to CY8CKIT-062S2-43012
  • Change WiFi config to match my network
  • Update MQTT broker to local network address, the port to 1883, turn off MQTT_SECURE_CONNECTION, and change MQTT_KEEP_ALIVE_SECONDS to 5. (Changing the keep alive to five seconds will reveal issue faster.)
  • Not necessary, but it cleans the UART output - comment out lines 262-276 in source/subscriber_task.c in  the mqtt_subscription_callback() function.

Once programmed, running, and connected, publish to the device with mosquitto_pub: mosquitto_pub -h 192.168.1.5 -t "ledstatus" -m "0123456"

The message "0123456" does not mean anything to the client as the processing of it is commented out -- I just want to see the connection work. The message gets through, but the client no longer sends a PINGREQ and the MQTT broker disconnects.

I've attached the output of the client and the relevant portion of Mosquitto broker log. Notice that the first client id is psoc6-mqtt-client8847 and after reconnecting, the id is psoc6-mqtt-client21675 which is reflected in both logs. I would've attached text files, but they are not allowed.

From the Wireshark capture, you can see that the broker closes the socket at the 13.712 s mark. This is roughly 7.5 seconds after the last PINGREQ from the client at the 6.138 s mark. 7.57 s is about 1.5 the keep alive time of five seconds set above.

Any help would be appreciated,

Matt

 

0 Likes
1 Solution
MattTreiber
Level 3
Level 3
25 sign-ins 10 replies posted 10 sign-ins

Thank you for looking into this. I first discovered this disconnect issue with v4.0.0 of this demo code and the v2.4 of ModusToolbox. However, I have since installed v3.0 of ModusToolbox and used the project creator (both CLI and GUI versions) to replicate issue. I posted the issue here:

https://community.infineon.com/t5/PSoC-6/Publishing-QoS-0-Messages-to-Anycloud-MQTT-Client-Causes-Br...

View solution in original post

0 Likes
2 Replies
Murali_R
Moderator
Moderator
Moderator
250 sign-ins 250 replies posted 100 solutions authored

Hello Matt

Apologies for the delay in response. We're trying to reproduce this and we will provide an update on this soon.

MattTreiber
Level 3
Level 3
25 sign-ins 10 replies posted 10 sign-ins

Thank you for looking into this. I first discovered this disconnect issue with v4.0.0 of this demo code and the v2.4 of ModusToolbox. However, I have since installed v3.0 of ModusToolbox and used the project creator (both CLI and GUI versions) to replicate issue. I posted the issue here:

https://community.infineon.com/t5/PSoC-6/Publishing-QoS-0-Messages-to-Anycloud-MQTT-Client-Causes-Br...

0 Likes