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.

CC3220: Issue connecting to simple MQTT broker: Error code -111, Bridge Disconnection.

Part Number: CC3220

Hiya,

I am working with a CC3220MODASF development board and the mqtt_client for freeRTOS & gcc that can be found via the code composer studio & resource explorer. I have performed the necessary alterations to the code to comply with my local hardware and such:

  • edited network_if.h to connect to a local access point, a phone hotspot (I am in an enterprise environment, and do not have a more robust setup available to something such as the CC3220). The connection goes through well, and is consistent and stable.
  • edited mqtt_client_app with the relevant settings for my broker, running via mosquitto on a Fedora VM, Windows host.

The three "devices": CC3220, Windows, and Linux share the same local network. A Windows client can easily subscribe to the Linux broker, however, what happens with the CC3220 is:

                 *************************************************
                    CC32xx MQTT client Application
                 *************************************************



Device came up in Station mode
[WLAN EVENT] STA Connected to the AP: Saana , BSSID: 2:1a:11:fd:85:f1
[NETAPP EVENT] IP acquired by the device

Device has connected to Saana
Device IP Address is 192.168.43.54

.........Connection to broker failed, Error code: -111
BRIDGE DISCONNECTION

On-board Client Disconnected

.
TO Complete - Closing all threads and resources
Unsubscribed from the topic /Broker/To/cc32xx
Unsubscribed from the topic /cc3200/ToggleLEDCmdL1
Unsubscribed from the topic /cc3200/ToggleLEDCmdL2
Unsubscribed from the topic /cc3200/ToggleLEDCmdL3

 Client Stop completed
reopen MQTT # 73

...or, in short, I get error code -111 every time I try to connect to my broker. The "stock" example project from TI connects to a remote broker just fine. Searching for the source or proposed solution for this error did not yield much results, so I am very open to suggestions.

  • Hi Konstantin,

    When connecting to the broker on your local network, I assume you are connecting via the IP address. Can you show me how you have updated the defines at the top of the MQTT application along with the Mqtt_ClientCtx struct?

    Thanks,
    Ben M
  • Hi Ben. It's Monday and I am back at work, hence the delay :-)

    Defines:

    #define SERVER_ADDRESS           "192.168.43.13"
    #define SERVER_IP_ADDRESS        "192.168.43.13"
    #define PORT_NUMBER              1883
    #define SECURED_PORT_NUMBER      8883
    #define LOOPBACK_PORT            1882

    I have kept the same stock structure for the ctx struct - unless I am wrong, doesn't it get its values by expanding the #define statements? I am somewhat of a beginner with C.

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

    Thanks for your help!

  • Hi Konstantin,

    The first field in the Mqtt_ClientCtx struct determines the connection type. Since the first field still has the MQTTCLIENT_NETCONN_URL flag included, it is treating the second field (SERVER_ADDRESS) as a URL and not an IP address. Try updating that to MQTTCLIENT_NETCONN_IP4 and retrying.

    Also, I recommend keeping the SERVER_ADDRESS define reserved for URLs and using the SERVER_IP_ADDRESS define when you are connecting based on a pre-set IP address for clarity.

    Best Regards,
    Ben M
  • Hi!

    Upon adjusting the struct as such, 

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

    The problem still remains unsolved, with the same issue. Do you have any other suggestions as to where the problem could stem from?

  • Hi Konstantin,

    Is the other client connecting to the Linux broker on the same port or is it using a secure connection? Can you see why the connection might be refused on the broker side? Or perhaps can you get a network capture of the connection attempt?

    Thanks,
    Ben M
  • The port is the same. The only possible reason of refusal that I can imagine is the network infrastructure at my workplace - but it'll take until Monday until I can verify that.

    I am working on wireshark captures of the attempts right now, I hope to post them on Friday. Thank you for your attention so far.
  • Hello again Ben,
    I would reckon that the problem is rooted in the company firewall implemented here: I brought my own laptop over to work today, and the CC3220 goes through to the mqtt broker running on the laptop just fine.

    Thank you for your help configuring the client on the CC3220 side, though!
  • Hi Konstantin,

    You're welcome! I'm glad you were able to change the setup a bit to test it and see it working. I'm going to go ahead and close this thread for now.

    Best Regards,
    Ben M