Hi,

I am trying to run a simple example SendDataOverMQTT which is provided in the XDK Workbench. I have made only these changes in the original code:

#define WLAN_SSID                           "iPhone"
#define WLAN_PSK                            "12345678"
#define APP_MQTT_BROKER_HOST_URL            "broker.hivemq.com"
#define APP_MQTT_BROKER_HOST_PORT           UINT16_C(1883)

 

However, every time I run this example it executes normally for only 128 seconds exactly. After 128 successful published messages I get this error:

 INFO | XDK DEVICE 1: AppMQTTSubscribeCB : #128, Incoming Message:
 INFO | XDK DEVICE 1: 	Topic: BCDS/XDK110/example/out
 INFO | XDK DEVICE 1: 	Payload: 
 INFO | XDK DEVICE 1: """
 INFO | XDK DEVICE 1: Environmental Data -
 INFO | XDK DEVICE 1: 	Humidity : 50
 INFO | XDK DEVICE 1: 	Pressure : 102002
 INFO | XDK DEVICE 1: 	Temperature : 24.401000ø
 INFO | XDK DEVICE 1: """
 INFO | XDK DEVICE 1: MqttEventHandler : Event - 15
 INFO | XDK DEVICE 1: MqttEventHandler : Event - 17
 INFO | XDK DEVICE 1: MqttEventHandler : Event - 4
 INFO | XDK DEVICE 1: AppControllerFire : MQTT publish failed 
 INFO | XDK DEVICE 1: Error in XDK110 Application package.
 INFO | XDK DEVICE 1: Error in XDK110 Application package.
 INFO | XDK DEVICE 1: 	Package ID: 153
 INFO | XDK DEVICE 1: 	Package ID: 153
 INFO | XDK DEVICE 1: 	Module ID: 39
 INFO | XDK DEVICE 1: 	Module ID: 39
 INFO | XDK DEVICE 1: 	Severity code: 2
 INFO | XDK DEVICE 1: 	Severity code: 2
 INFO | XDK DEVICE 1: 	Error code: 123
 INFO | XDK DEVICE 1: 	Error code: 125
 INFO | XDK DEVICE 1: AppControllerFire : MQTT publish failed 

 

This happens very consistently. 

Further Information:

XDK Workbench version: Latest

Bootloader: 1.1.0

 

---Salman

0 (0 투표)
RE: SendDataOverMQTT example works for only two minutes (Aprx.)
응답
19. 7. 24 오전 6:55 as a reply to Muhammad Salman Shaukat.

Hello Muhammad,

i do not think there is a problem in your code. The behavior you are you are observing is normal. You are publishing periodically messages to a public MQTT broker. To avoid spamming this public broker automatically disconnects clients after some time and some amount of published messages. If you want to publish data with a higher frequence or over a longer time interval I would recommend to programm your own simple MQTT broker.

I hope this was helpfull.

Best regards,

Christian

+1 (1 투표)
RE: SendDataOverMQTT example works for only two minutes (Aprx.)
응답
19. 7. 24 오전 7:20 as a reply to Christian Köhler.

Hello Muhammad,

As said by Christian, this MQTT connection failure is due to the broker.

I recommend you to implement a reconnect logic in case of connection failure.

0 (0 투표)
RE: SendDataOverMQTT example works for only two minutes (Aprx.)
응답
19. 7. 25 오후 2:10 as a reply to Padmapriya G.

Hi Christian,

Thanks for your reply. After your helpful suggestion, i used Mosquitto broker (Windows) and tried to use it on my XDK device. However, i was not successful in doing so and got the following error:

 INFO | XDK DEVICE 1: WLANPersonalWPA2Connect : Connected to WPA network successfully. 
 INFO | XDK DEVICE 1: MqttEventHandler : Event - 2
 INFO | XDK DEVICE 1: AppControllerFire : MQTT connection to the broker failed 
 INFO | XDK DEVICE 1: MqttEventHandler : Event - 3
 INFO | XDK DEVICE 1: Error in XDK110 Application package.
 INFO | XDK DEVICE 1: 	Package ID: 153
 INFO | XDK DEVICE 1: 	Module ID: 39
 INFO | XDK DEVICE 1: 	Severity code: 2
 INFO | XDK DEVICE 1: 	Error code: 122

 

However, i was able to connect to the same mqttbroker (mosquitto) using a windows application called "mqtt.fx" . Which means that mosquitto server is running fine on windows but there is some issue connecting it to the xdk device. I would appreciate any help in this matter. 

Best regards,

Salman

0 (0 투표)