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.

CC3200 MQTT Server Address(Broker Address)

Other Parts Discussed in Thread: CC3200

Hi all.

I'm testing the MQTT Client.

My test is OK by "CC32xx MQTT Client.pdf".

By the way, I want to use IP Address for "SERVER_ADDRESS"

So I changed the source as follows.

#define SERVER_ADDRESS          "messagesight.demos.ibm.com"

connect_config usr_connect_config[] =
{
    {
        {
            {
                SL_MQTT_NETCONN_URL,
                    SERVER_ADDRESS,
                    PORT_NUMBER,
                    0,
                    0,
                    0,
                    NULL
            },
            SERVER_MODE,
            true,
        },
        NULL,
        "0.1.0.0001.001.001",
        NULL,
        NULL,
        true,
        KEEP_ALIVE_TIMER,
                {Mqtt_Recv, sl_MqttEvt, sl_MqttDisconnect},
                TOPIC_COUNT,
                {TOPIC1, TOPIC2, TOPIC3},
                {QOS2, QOS2, QOS2},
                {WILL_TOPIC,WILL_MSG,WILL_QOS,WILL_RETAIN},
                false
    }
};

#define SERVER_ADDRESS          "75.126.71.163"

(I checked the IP address by "ping messagesight.demos.ibm.com" on the console.)

connect_config usr_connect_config[] =
{
    {
        {
            {
                SL_MQTT_NETCONN_IP6,
                    SERVER_ADDRESS,
                    PORT_NUMBER,
                    0,
                    0,
                    0,
                    NULL
            },
            SERVER_MODE,
            true,
        },
        NULL,
        "0.1.0.0001.001.001",
        NULL,
        NULL,
        true,
        KEEP_ALIVE_TIMER,
                {Mqtt_Recv, sl_MqttEvt, sl_MqttDisconnect},
                TOPIC_COUNT,
                {TOPIC1, TOPIC2, TOPIC3},
                {QOS2, QOS2, QOS2},
                {WILL_TOPIC,WILL_MSG,WILL_QOS,WILL_RETAIN},
                false
    }
};

But I get the message "Broker connect fail for conn no. 1".

Can I connect a broker with IP address?

Best regards.

  • Hi,

    You can use the IP addresses as it is. Please make sure you do not change anything else and use the sample code as it is.
    But only replace the server address i.e, only define SERVER_ADDRESS.

    And make sure that the AP connected to CC3200 has internet connectivity.

    Regards,
    Raghavendra
  • Hi Raghavendra.

    Thanks for your description.

    I am testing well.

    I misunderstand this comment in Sl_mqtt_client.h.

    typedef struct {

    #define SL_MQTT_NETCONN_IP6  0x04  /**< Assert for IPv6 connection, otherwise  IPv4 */
    #define SL_MQTT_NETCONN_URL  0x08  /**< Server address is an URL and not IP address */
    #define SL_MQTT_NETCONN_SEC  0x10  /**< Connection to server  must  be secure (TLS) */

                    _u32         netconn_flags; /**< Enumerate connection type  */
                    const char          *server_addr;   /**< Server Address: URL or IP  */
                    _u16       port_number;   /**< Port number of MQTT server */
                    char        method;        /**< Method to tcp secured socket */
                    _u32         cipher;        /**< Cipher to tcp secured socket */
                    _u32         n_files;       /**< Number of files for secure transfer */
                    char * const        *secure_files;  /* SL needs 4 files*/

            } SlMqttServer_t;

    Have a good day^^

    Regards,

    Gwanyoung Kim.

  • Hi Raghavedra,

    Can I connect a broker with IP address?

    I'm running a MQTT broker on a Raspberry-Pi and I want to connect the CC3200 to it using the Raspberry IP address.
    I try what Kim is doing but I get the same message, the CC3200 has internet acces and I can connect it to different brokers, but until now, just using the URL of the broker, I try with the IP that Kim gives but neither that works.
    I can connect to the broker on the Raspberry-Pi using another applications.
    Any ideas of what I'm missing or what is the problem, or even if is it possible?

    Regards, Juan
  • Hi Juan.

    Did you use what definition for the Server Address?

    I used the "SL_MQTT_NETCONN_IP6" not the "SL_MQTT_NETCONN_URL".
    I encountered the error "Broker connect fail for conn no. 1", when I have used the "SL_MQTT_NETCONN_URL".

    Best regards,
    Gwanyoung Kim.
  • Hi Gwanyoung Kim

    I have tried with both definitions but none of them works. Right now I have that code in standby but on a few days when I'll try it again I'll try to connect to a different broker by Ip.
    I've reading and maybe I can't connect to the broker on the Raspberry-Pi through internet using just the ip address. If I solve the problem I'll post it, if somebody have another suggest is welcome.

    Regards, Juan
  • Hi Juan,

    did you solve the problem? I got the same error, when I try to connect to my broker with IP adress.
    "Broker connect fail for conn no. 1".

    Regards, Jan
  • I an working on connecting to broker by IP address. Have you found any solution? Please help us! Thanks a lot.
  • Hi.

    What do you use netconn_flags member of the SlMqttServer_t?

    The "SL_MQTT_NETCONN_URL" is right.

    And the server_addr is a string. For example, "123.123.123.123".

    regards.

  • Thanks Gwanyoung Kim first. I suddenly find out my example is  CC3200 example client. 

    The main idea I want to do is that using cc3200 to connect wifi and publish data to "mosquitto(my broker) " . And here is my code


    SL_MQTT_NETCONN_IP6,     <<== I have tried use both SL_MQTT_NETCONN_URL and SL_MQTT_NETCONN_IP6
    SERVER_ADDRESS,               <<==  sever address is 192.168.3.4(my IP)
    PORT_NUMBER,
    0,
    0,
    0,
    NULL
    },
    SERVER_MODE,
    true,
    },
    NULL,
    "user1",
    NULL,
    NULL,
    true,
    KEEP_ALIVE_TIMER,
    {Mqtt_Recv, sl_MqttEvt, sl_MqttDisconnect},
    TOPIC_COUNT,
    {TOPIC1, TOPIC2, TOPIC3},
    {QOS2, QOS2, QOS2},
    {WILL_TOPIC,WILL_MSG,WILL_QOS,WILL_RETAIN},
    false

    according to example, if I connect my broker  and push button SW2, SW3 . It will appear in my subscriber.

    But I even couldn't connect to my broker.

    Is there anything else I should verify?

    BTW, when I tried to run the example directly to IBM server. The IBM sever have seemed to shut down.

     

     

  • Hi.
    I can't connect local IP too.(192.168.x.x). I don't know why.
    And I think the IBM server is shut down too.
    Also, you can test the broker with "iot.eclipse.org".
    Rregards.

  • Thanks a lot. I have tested it successfully with www.hivemq.com/.../.
    And It's said build broker on window might some unknown problem.
    It's better building on Linux
  • Oh, really?

    Thanks a lot.