This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP-EXP432E401Y: MQTT connection error

Part Number: MSP-EXP432E401Y

Hi Ti Expert,


I have MSP-EXP432 development board www.ti.com/.../MSP-EXP432E401Y. And I want to connect this board with local mqtt

I started local mqtt broker (mosquitto:- https://mosquitto.org/)
It's running successfully. It checked by MQTTbox app.(mqttbox.en.softonic.com/)

What is changes are require in MQTTclient example ?
(C:\ti\simplelink_msp432e4_sdk_4_20_00_12\examples\rtos\MSP_EXP432E401Y\ns\mqttclient)
I am using Firewall.


for testing, I done some changes in mqtt_client_app.c file.


Changes in:- mqtt_clinet_app.c

#define SERVER_ADDRESS "localhost" //1
or
#define SERVER_IP_ADDRESS "127.0.0.1" //2

And
MQTTClient_ConnParams Mqtt_ClientCtx = {
MQTTCLIENT_NETCONN_URL, // 1
SERVER_ADDRESS, // 1
PORT_NUMBER, 0, 0, 0, NULL
};

Or

MQTTClient_ConnParams Mqtt_ClientCtx = {
MQTTCLIENT_NETCONN_IP4, //2
SERVER_IP_ADDRESS, //2
PORT_NUMBER, 0, 0, 0, NULL
};


Note:- only one option is uncomment 1 or 2
if using "localhost" -> uncomment 1 and comment 2 option
if using "127.0.0.1" -> uncomment 2 and comment 1 option


But still not connect with local mosqitto mqtt broker.

Got Error:- Trigger this event "MQTTClient_DISCONNECT_CB_EVENT"
And print "BRIDGE DISCONNECTION".

If anything else missing in change, please correct inform me.

Thanks in advance

Regards,
Darshan

  • Hi,

      The example use https://mosquitto.org as the broker. Please run the example as is first and make sure it is working as expected. You change to SERVER_ADDRESS "localhost". localhost normally means the MCU itself. Same for 127.0.0.1 which is local loopback address. Not sure why you setting the SEVER_IP_ADDRESS to 127.0.0.1.  If you want to run MCU as a broker you can also take a look at the example C:\ti\simplelink_msp432e4_sdk_4_20_00_12\examples\rtos\MSP_EXP432E401Y\ns\mqttclientserver. 

  • I also ran the example as is and it works. See below. 

    - First install a another mqtt client app on my phone. 

    - connect to the broker at test.mosquitto.org

    - subscribe to the topic /Broker/To/simplelink and provide a test message. See below. 

    - Click the Publish button. 

    - In the client terminal window, I see the message displayed. See below. 

    - I press the button on the LaunchPad and the client send a message 'Push Button 0 has been pressed on SimpleLink device'. See below. 

    - On my phone client subscribing to the same topic '/simplelink/ButtonPressEvt0', I see the same message. 

  • Hi  Charles Tsai,

    Thanks for the give response on my query.

    1) Yes, it working with test.mosquitto.org

    2) I started mosqitto broker on PC. And MCU and PC are interconnected using Ethernet port via Ethernet Switch.

    3) I am using Firewall. And I don't know how to bypass MCU ethernet in firewall. Without internet, it can't connect with broker

    4) I tested mqttclientserver project and It's working fine.


    How to solve this problem?

    Mosqitto borker is working. I tested with sub/pub on mqttbox app. but not connect with mcu.


    Best Regards,
    Darshan

  • Hi,

      I don't know how to bypass the firewall. You might need to contact your IT department if there is a way to bypass the firewall for some IP address like test.mosquitto.org. Please also try run on a network without firewall maybe like your home network to get a feel for the example. 

  • Hi ,

    I also try enter IP address of local pc which have started mqtt broker, still not working.


    Regards,
    Darshan

  • Hi,

      I look up DNS for test.mosquitto.org and the IP address is 91.121.93.94. I change the SERVER_ADDRESS as follows and it works for me. On my phone, I can publish to /simplelink/ToggleLEDCmdL0 and I will see the LED turned ON on the board. This means either a URL "test.mosquitto.org" or IP "91.121.93.94" can be entered. 

    //#define SERVER_ADDRESS "test.mosquitto.org"
    #define SERVER_ADDRESS "91.121.93.94"

    This is what I see on the terminal window as well as the physical LED on the board turned ON or OFF when I publish to the topic on my phone using SERVER_ADDRESS "91.121.93.94".

      I don't have a great depth of knowledge in MQTT as to why it does not work with your local broker. A couple of things you might want to check and try.

    Have you tried the stock example yet? Can you get it to work in a non-firewall environment? I really think you should first demonstrate that the MQTT client will work with the broker test.mosquitto.org. Because if it works with the remote broker then you can investigate what is the difference between the remote broker and your local broker.  

    Is your MQTT client and local PC broker on the same network and same subnet? Your local switch may not route the packets if not in the same subnet. 

    Can you try on a different network like home network? Earlier you said you have firewall in your network. I don't know if that prevents your code from working.