Developer Portal Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    SendDataOverMQTT Error

    Highlighted

    SendDataOverMQTT Error

    Hello,

    I have been trying to get the example project SendDataOverMQTT to work for the past few days, but am currently stuck. This is using Workbench version 3.6.1. I’ve tried to follow the relevant guides and forum posts. After flashing the project to the XDK I get the following output (abbreviated):

    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: 134

    The only changes I made to the example project were editing the WiFi and MQTT settings in the app header file (XDK is connecting to WiFi so that doesn't seem to be a problem). MQTT settings are as follows:

    #define APP_MQTT_BROKER_HOST_URL "broker.hivemq.com"

    #define APP_MQTT_BROKER_HOST_PORT UINT16_C(1883)

    I have also tried setting the host URL to "test.mosquitto.org" but either way I've had no luck. I can ping both URLs from the command line so I believe the problem is on the XDK side. As far as I can tell the error is coming from the MQTT module of the XDK application, but I can't make sense of the 134 error code. As for the MqttEventHandler outputs, I think these correspond to MQTT_CONNECT_SEND_FAILED and MQTT_CONNECT_TIMEOUT, respectively. I'm not sure if this means that the XDK initially connects to the MQTT broker and then the send fails or if there is never any connection at all. I've tried re-importing the example several times but each time I get the same error.

    Again, I'm getting this error after only changing the four lines in the app header file that I mentioned. Reading through the documentation I've tried changing a few more things but still get the same error:

    - Changing line 61 in Serval_Defines.h from #define SERVAL_ENABLE_MQTT 0 to #define SERVAL_ENABLE_MQTT 1 (does this enable support for the MQTT protocol?)

    - Changing the package contents from the humidity, pressure and temp sensor outputs to "test" (I tried the example StreamSensorDataOverUsb and got it to work, so I don't think the problem is with the sensors)

    - Changing various values in the AppController.c file, such as increasing the various timeout variables on lines 83-87, increasing the .KeepAliveInterval on line 176, activating and deactivating various sensors, and changing the QOS levels for subscribe and publish.

    I'm considering either deleting and reinstalling the XDK software (maybe I mistakenly changed something in the original example file) or trying this on a different WiFi network (perhaps I need special permissions to send data over MQTT?). I'm still new to using the XDK so any help would be appreciated. 

    Thanks,

    Sam

     

    5 REPLIES 5
    Highlighted
    Senior Member

    Re: SendDataOverMQTT Error

    Hello,

    From the error code mentioned, XDK is unable to connect to MQTT broker. Are you using secured/unsecured MQTT connection ?

    Also ensure whether valid server broker is used.

    Changing WiFi network may not be necessary since your XDK is connected to WiFi network successfully. Please make sure your WiFi network has internet access to reach the extenal broker like mosquitto/hive.

    There is no need to reinstall XDK workbench for XDK connection error with broker.

    Highlighted

    Re: SendDataOverMQTT Error

    Hi Padmapriya,

    Thanks for the reply. I'm using an unsecured MQTT connection; APP_MQTT_SECURE_ENABLE is set to 0 in the header file. I think that both broker.hivemq.com and test.mosquitto.org are valid brokers. I'm able to connect to the HiveMQ browser client and when I ping test.mosquitto.org I get a response. Is there another way to see if these are valid?

    Sam

    Highlighted
    Senior Member

    Re: SendDataOverMQTT Error

    Hello,

    I have downloaded XDK workbench v3.6.1 and use the SendDataOverMQTT application.

    I used local mosquitto broker and following  configurations has been changed in AppController.h,

    1. WLAN_SSID
    2. WLAN_PSK
    3. APP_MQTT_BROKER_HOST_URL
    4. APP_MQTT_BROKER_HOST_PORT - 1883

    Environment sensor data has been received in MQTT broker. Attached screenshot.

     
     

    Possible issues with your setup,

    1. MQTT broker port is not configured correct
    2. MQTT broker is not running
    3. Firewall is blocking
      1. Request you to check in sniffer tools like Wireshark, and see whether data from XDK is sent to destination IP successfully

    Re: SendDataOverMQTT Error

    Hi Padmapriya,

    Thanks for the reply. I did some more testing. As you showed, I was able to connect to a locally hosted Mosquitto broker with the XDK. In addition, using Eclipse Paho I am able to connect my PC to test.mosquitto.org, broker.hivemq.com, iot.eclipse.org and even an MQTT broker I created through AWS. I am not able to connect to these using the XDK. As you pointed out I think the Firewall on my local network is blocking the XDK from connecting to these brokers. Have you heard of this happening before? I'll do some more testing and let you know what I find.

    Sam

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist