I am working with the SendDataOverMQTT project that comes with the XDK workbench 3.5.0(unmodified), and a seperate project that I have modified.  Both use the same basic structure for publishing and subscribing messages to the broker.hivemq.com MQTT Broker.  Both of them stop after exactly 128 messages have been published and subsequently received.

Is there a limitation in the code that is causing this to stop after exactly 128 messages?  I have tried to increase the stack size for the AppControllerFire task and the mess with the publish rate, but neither of those had an effect.

Is there a way to monitor the connection to the MQTT Server and reconnect if it fails?  I can see the MQTT event handles track this but would like to call an API rather than edit the SDK.

Thank you for your help,

Christopher Koch

0 (0 Votes)
RE: MQTT Fails after 128 Messages (WB 3.5.0)
Answer
2/7/19 2:02 PM as a reply to BCDS Tester.
Hello Chris,

I guess that this is a limitation by the HiveMQ MQTT Broker. Since its a public service, I can imagine that the service has set a maximum message counter to prevent user from spamming the broker.

I have tested the HiveMQ broker and had the same behavior getting disconnected from the broker after 128 messages. I also tested the same implementation with my local Mosquitto MQTT broker. There I included no limitations in regards to the message count and the SendDataOverMQTT example run through without getting disconnected.

Please tell me if this was helpful, and do not hesitate to ask further questions.

Kind regards,
Franjo
0 (0 Votes)
RE: MQTT Fails after 128 Messages (WB 3.5.0)
Answer
2/7/19 3:59 PM as a reply to Franjo Stjepandic.

Franjo,

Thanks for this answer.  I didn't think about the limitation being on the broker itself.

One follow up question.  Is there a way for the user application to monitor the status of the MQTT connection?  In the past I know this could be lost while the XDK stayed connected to the WiFi, so it would be good to monitor this and reconnect if that connection is lost.  I see the MQTT API monitors the connection status, but this is monitored with a local variable in the API, so it is not availabel to the User Application.  As always I know how to get it to work by changing the SDK but prefer not to do this.

Thanks again for your help.

Christopher Koch

0 (0 Votes)
RE: MQTT Fails after 128 Messages (WB 3.5.0)
Answer
2/7/19 4:50 PM as a reply to BCDS Tester.
Hello Chris,

I am always happy to help. If you are using the implementation from the XDK_MQTT.h API, this is not possible because the functionality is not integrated yet.

But if you are intending to go one layer down to the underlying ServalStack implementation Serval_Mqtt.h , then you will be able to build up this functionality in your application. There you are able to monitor the connection actively or reactively by reconnecting every time a disconnect or timeout event is thrown by the API.

As starting point, you could use the full code implementation from the XDK knowledgebase . Please note you need to register an account beforehand to access the content of the XDK knowledgebase.

Changing the SDK might not be necessary this time.

Please let me know if this was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
0 (0 Votes)
RE: MQTT Fails after 128 Messages (WB 3.5.0)
Answer
2/7/19 8:41 PM as a reply to Franjo Stjepandic.

Franjo,

Thanks as always for your great help.  I will look into this lower level code and see if I can implement something to monitor the connection.

Christopher Koch

0 (0 Votes)