MQTT failed after successful sending
Risposta
25/06/19 10.22

Hi,

I am new to XDK coding.  I used the SendDataOverMQTT example from Workbench 3.6 to send data to the Mosquitto MQTT broker over same WiFi network.  The XDK was able to connect to WiFi and sucessfully published its measured data to the broker but failed after half a minute.  After switching off and re-switching on the XDK, it woked a short while and got the same error result.

The log when error happened is shown below.

 INFO | XDK DEVICE 6: Topic: node/group01/XDK110/XDK17-02274

 INFO | XDK DEVICE 6: Payload: {"payload":"data","type":"magz","value":-54}

 INFO | XDK DEVICE 6: MqttEventHandler : Event - 15

 INFO | XDK DEVICE 6: MqttEventHandler : Event - 14

 INFO | XDK DEVICE 6: AppMQTTSubscribeCB : #128, Incoming Message:

 INFO | XDK DEVICE 6: Topic: node/group01/XDK110/XDK17-02274

 INFO | XDK DEVICE 6: Payload: {"payload":"data","type":"ligh","value":54720}

 INFO | XDK DEVICE 6: MqttEventHandler : Event - 17

 INFO | XDK DEVICE 6: MqttEventHandler : Event - 4

 INFO | XDK DEVICE 6: AppControllerFire : MQTT publish failed 

 INFO | XDK DEVICE 6: Error in XDK110 Application package.

 INFO | XDK DEVICE 6: AppControllerFire : MQTT publish failed 

 INFO | XDK DEVICE 6: Package ID: 153

 INFO | XDK DEVICE 6: AppControllerFire : MQTT publish failed 

 INFO | XDK DEVICE 6: Module ID: 39

 INFO | XDK DEVICE 6: Error in XDK110 Application package.

 INFO | XDK DEVICE 6: Severity code: 2

 INFO | XDK DEVICE 6: Package ID: 153

 INFO | XDK DEVICE 6: Error code: 123

 INFO | XDK DEVICE 6: Module ID: 39

 INFO | XDK DEVICE 6: Severity code: 2

 INFO | XDK DEVICE 6: Error code: 130

 

And here is the parameters setting on AppController.h.

#define WLAN_SSID                           "AAAAAA"

#define WLAN_PSK                            "bbbbbbb"

#define WLAN_STATIC_IP                      false

#define WLAN_IP_ADDR                        XDK_NETWORK_IPV4(0, 0, 0, 0)

#define WLAN_GW_ADDR                        XDK_NETWORK_IPV4(0, 0, 0, 0)

#define WLAN_DNS_ADDR                       XDK_NETWORK_IPV4(0, 0, 0, 0)

#define WLAN_MASK                           XDK_NETWORK_IPV4(0, 0, 0, 0)

#define SNTP_SERVER_URL                     "YourSNTPServerURL"

#define SNTP_SERVER_PORT                    UINT16_C(123)

#define APP_MQTT_BROKER_HOST_URL            "192.168.43.109"

#define APP_MQTT_BROKER_HOST_PORT           UINT16_C(1883) //0

#define APP_MQTT_CLIENT_ID                  "XDK17-02274" //"XDK_MQTT_EXAMPLE"

#define APP_MQTT_TOPIC                      "node/group01/XDK110/XDK17-02274"

#define APP_MQTT_DATA_PUBLISH_PERIODICITY   UINT32_C(50)

 

Could anyone please advise on the possible causes and help to fix the problem.  Thank you very much.

0 (0 Voti)
RE: MQTT failed after successful sending
Risposta
26/06/19 8.42 come risposta a Sran Sribhibhadh.

Hi Sran,

I'm not sure, but I think you need to reduce the frequency. Currently you have set 50 which means that you want to send 20 times per second. Try it with 1 time per second. So define this:

#define APP_MQTT_DATA_PUBLISH_PERIODICITY   UINT32_C(1000)

0 (0 Voti)
RE: MQTT failed after successful sending
Risposta
26/06/19 9.35 come risposta a Saeid Kajlar.

Hello Sran,

i am not sure what causing this error either, but i think the hint from Saeid could be the solution.

In the following i will explain the error information you get. Maybe this will help you to solve the problem.

MqttEventHandler: Event - 17 --> MQTT_PUBLISH_SEND_FAILED
MqttEventHandler: Event - 4   --> MQTT_CONNECTION_CLOSED

So it seems your programm fails to publish a message and close the connection after that.

Error code: 123 --> RETCODE_SENSOR_NONE_IS_ENABLED

I hope this was helpfull.

Best regards,

Christian

0 (0 Voti)
RE: MQTT failed after successful sending
Risposta
27/06/19 0.38 come risposta a Christian Köhler.

Hi Christian,

Thank you for your explanation.  By the way where can I find the error codes.  Are they in the Bosch documents or in the related library codes?  May you please advise so I can self-checked when the errors happen.

Best regards,

Sran S.

0 (0 Voti)
RE: MQTT failed after successful sending
Risposta
27/06/19 0.43 come risposta a Sran Sribhibhadh.

Hi Saeid,

Thanks for your clear answer. I intentionally stretched the XDK to publish very fast. I will try to set longer period and see how it goes. 

Best regards,

Sran S. 

0 (0 Voti)
RE: MQTT failed after successful sending
Risposta
27/06/19 7.19 come risposta a Sran Sribhibhadh.

Hello Sran,

you can find the error codes related to MQTT in the file Serval_Mqtt.h in the following path:

YourProject/SDK/xdk110/Libraries/ServalStack/3rd-party/ServalStack/api/Serval_Mqtt.h

The common error codes are listed in the document XdkCommonInfo.h in the path:

YourProject/SDK/xdk110/Common/inlcude/XdkCommonInfo.h.

Furthermore i just remembered an interesting fact about free online brokers. I only know that behaviour from the HiveMq broker, but maybe the mosquitto behaves in the same way. To avoid spamming clients free online brokers disconnect your client after an amount of time if you are periodically publish messages. Maybe this is the reason of your disconnect.

I hope this was helfpull.

Best regards,

Christian

 
 
+1 (1 Voto)
RE: MQTT failed after successful sending
Risposta
28/06/19 0.20 come risposta a Christian Köhler.

Hi Christian,

Your info on error codes are very useful.  For your information I run Mosquitto MQTT broker on local Linux PC and XDK is only a client that publishes to the broker.  I will try to test more with different parameter settings to see how the system behaves.

 

Best regards,

Sran S. 

0 (0 Voti)
RE: MQTT failed after successful sending
Risposta
09/07/19 1.53 come risposta a Sran Sribhibhadh.

Hi all,

After many trials on setting the publish periods from very fast (50 mS) to slow (5000 mS), it helps a little but still failed after around 10 minutes.  I did two things:

1. Change the MQTT publish QoS from the default 1UL to 0UL.

2. Combine many sensor values to one JSON message payload instead of sending individual sensor. 

With above changes, I am now able to publish to MQTT at very fast rate (100 mS) and no failure so far.

Regards, 

0 (0 Voti)