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.

CC3220SF: How to access CC3220 MQTT broker/server by domain name?

Part Number: CC3220SF

Hi,

I am using "simplelink_cc32xx_sdk_2_30_00_05", I am doing MQTT communication between CC32200 devices, where all shared same NW. But I don't want to use the IP address of my server which is changing by my Gateway some times on Reset/Replace-Gateway.

So, I want to make a static Domain name like "Example.com", how to do this in CC3220?  

Thank you.

  • Hi,

    I am not familiar with MQTT example. But at host driver is sl_ API sl_NetAppDnsGetHostByName(). This API you can use to resolving hostnames.

    Jan
  • Hi Jan,
    The ans you suggest is for DNS sever mode.
    Now my device is in STA mode, how about this?
    Thank you.
  • Hi,

    - In case of that you want to use DNS, DNS server need to run on your network infrastructure.
    - Another option for "communication" between CC32xx device can be usage of mDNS.

    Jan
  • Hi Jan,  

    I tried to do as below in my MQTT broker

     sl_NetCfgGet(SL_NETCFG_IPV4_STA_ADDR_MODE,&ConfigOpt,&ipLen,
                     (uint8_t *)&ipV4);
    
        DestinationIP = ipV4.Ip;
    
        UART_PRINT("My IP is %d.%d.%d.%d\n\r", \
                   SL_IPV4_BYTE(DestinationIP,3),  \
                   SL_IPV4_BYTE(DestinationIP,2),  \
                   SL_IPV4_BYTE(DestinationIP,1),  \
                   SL_IPV4_BYTE(DestinationIP,0));
    
       int res1 = sl_NetAppDnsGetHostByName("www.myti.com", strlen("www.myti.com"), &DestinationIP,SL_AF_INET);
       UART_PRINT("res1 = %d \r\n", res1);

    In prints I am getting my IP and res1 also printing success code "0".

    But when I tried to publish msg to this from my client which is shared same NW I am getting 

    "Error: The connection was last."

    Same is publishing with IP addr

    Thank you

  • Hi,

    I don't understand your code. It not make sense, especially what you mean by DestinationIP variable.

    You should check first that proper IP address is returned from sl_NetAppDnsGetHostByName() API call. This you can compare with DNS lookup from your computer. After that you can use this IP in your code as you want. In case you want to send data outside your LAN, do not forget that gateway, subnet mask need to be properly configured at your CC32xx device.

    BTW ... did your read in documentation what is purpose of sl_NetAppDnsGetHostByName() API? This API is for obtain IP from domain name not vice versa.

    Please read wiki page how DNS or mDNS works.

    Jan

  • Hi Jan,

    WiresharkDebug.zip

    I tried to debug with Wireshark, pls find the attach for debug info

    My MQTT server as I posted above "www.myti.com"  IP is "192.168.225.215"

    My client trying to publish is "192.168.225.104", successfully publishing with IP address. When I published to host "www.myti.com" destination IP is showing "216.157.88.26" in wireshark.

    Please let me know any solutions.

  • Hi,

    IP address of "www.myti.com" in Internet at my side is 216.157.88.23 and you get 216.157.88.26. This looks OK, because both addresses are at same subnet. This difference may to be due to different location and usage different DNS caching servers. Result: sl_NetAppDnsGetHostByName() at your side works without any issue and you get proper IP from DNS lookup.

    As to be honest, I am not sure if you really understand how DNS works and what is purpose for GetHostByName.

    Jan

  • Hi Jan,
    I need Domain name to the IP, I am clearly telling in this thread subject.
    My need: I have Dev1 MQTT server.
    I have Dev2, Dev3 & Dev4 are MQTT client.
    all 4 are connected to my third-party Gteway/WiFi-AP.
    In this network I want to do MQTT Pub/Sub's using sever name like "http://example.com" which is acquired by IP "192.168.225.215"

    I think this is clear, if it is How to do this?
    Thank you.
  • Hi,

    I answered this question in my 2nd post. You have two options:

    - you can use DNS for this purpose but you need set DNS server at your network infrastructure

    - you can use mDNS/Bonjour or some other Zero-Conf protocol implemented by yourself. mDNS is supported by CC3220 devices (see swru455 at chapter 9).

    Jan

  • Hi Jan,
    Can you pls brief which is less time taken and how to achieve one of the your suggestion. I have less knowledge on DNS and mDNS.
    Thank you
  • Hi,

    This depends on your requirements and capabilities (of you and your customers in case of you designing commercial device). But in brief few hints, because I am not able (and don't want to) explaining you how DNS or mDNS works. This need to study by yourself (and you should really do that).

    - Fastest way it to use DNS, but you need to be able configure DNS server at network infrastructure. That means you need to have network infrastructure with this capability and you need to have knowledge how set this. This way can be problematic in case you designing commercial device for users with low level of knowledge at networking area.

    - Usage of mDNS is slightly more complex (need to be integrated at server as client code as well). But usage of mDNS is slightly more universal. How to use mDNS is described at SWRU455 and demostrated at serial_wifi example in SDK.

    Jan
  • Hi Jan,
    Thank you for suggestion.
    We are doing this to our client. I am working in our prototypes which is fabricated recently with CC3220MODASF. At any cost I have to achieve this, can you please brief little more to do this with serial_wifi example in SDK.

    where can I find SWRU455?
  • Hi,

    I already provided link to SWRU455 at my previous answer or you can use google.

    At beginning you should look to to API sl_NetAppDnsGetHostByService() and  sl_NetAppMDNSRegisterService().

    Jan

  • Hi Jan,
    Thank you.
    Can you help me to ping "serial_wifi" example project running in CC3220 using "DNS" from my PC, where both shared the same NW.
  • Hi,

    All information about mDNS you find at SWRU455.

    - mDNS protocol is not supported by Windows itself. At Windows platform you need to use 3rd party application (Windows internally supports LLMNR protocol only).
    - mDNS is fully supported at Apple devices (MAC, iPhone)
    - at Android you need to use 3rd party application to discovery devices via mDNS

    Jan
  • Hi Jan,

    Thank you for info.

    I am using Android application "Service Browser" to see the available mDNS services in my local NW.

    When I run the "serial_wifi" example as it is I can see the names

    "_http._tcp.(World Wide Web HTTP)" and "_uart._tcp" in my app.

    I tried by below change

    #define SERIALWIFI_DNS_NAME                 "mytest.local"                /* (before it is "CC32xx._uart._tcp.local") */

    where both sl_NetAppDnsGetHostByService and sl_NetAppMDNSRegisterService are usingsame service name "SERIALWIFI_DNS_NAME"

    what is wrong in my name "mytest.local"? which is not visible to my app.

    How to ping the same? i mean for the service name "CC32xx._uart._tcp.local", what URL i have to ping.

    Thank you

  • Hi,

    I am not familiar with this Android App, from this reason I am not able help you with this 3rd party application.

    Specification of mDNS protocol you find at RFC 6762.

    Jan

  • Hi Jan,
    I am trying to ping(Querying) from android device to the "serial_wifi" example, but getting response unknown host.
    can you pls help to ping "serial_wifi" example project? by mDNS service name "mytest.local".

    Thank you
  • Hi,

    You cannot ping domain name .local if mDNS is not supported by OS itself (Windows, Android). At this platform you need discovery IP by 3rd party application and use this IP for ping. At Widnows are addresses .local resolved by LLMNR protocol not mDNS. If you need native resolving .local at Windows, you need to implement LLMNR into CC3220 by yourself.

    Jan
  • Hi Jan,
    Can you help to test with IoS?
  • Hi,

    I haven't iOS device. But .local addresses should be resolved at Apple devices without any issue.

    Jan
  • Hi Jan,
    I can able to pub/sub to my cc3220 mqtt broker with host name "mytest.local" from my WIndows10 PC sharing same NW.

    So, now I am trying to connect my CC3220 mqtt client to same broker with SERVER_ADDRESS "neciot.local", but getting
    "Connection to broker failed, Error code: -2006"

    The same setup working good with IP address.
    Do you have any suggestions.

    Thank you.
  • Hi,

    - What API do you use for resolving .local address inside your CC3220 mqtt client? Do you use sl_NetAppDnsGetHostByService()?
    - How do you resolve mytest.local at your Windows 10 device? What build of Windows 10 do you use?

    Jan
  • Hi Hnz,
    I am not using any of mDNS API's as discussed in this thread.
    I simply changed below things in my cc3220 MQTT broker

    ConfigureSimpleLinkToDefaultState(){
    ...................................
    unsigned char devicestr[32] = "mytest";
    unsigned char domainstr[32] = "www.mytest.net";
    ................................
    }

    Using mosquito in "Windows10 pro" to pub/sub to my broker with host "mytest.local"
    And I tried the same in one more CC3220 MQTT client where pub/sub are working good with Server name "mytest"

    This is worked in NW where all my devices are stations.
  • Hi,

    What exact example at SDK do you referring? I am not able find strings devicestr[] and domainstr[] in any example SDK example. To be able resolve .local address at CC3220 you need to use mDNS.

    NetApp option SL_NETAPP_DEVICE_DOMAIN is used for AP mode only. Please see SWRU455 at chapter 3.10.

    Jan

  • Hi Jan,
    I am using "simplelink_cc32xx_sdk_2_30_00_05", you can find in provisioning task.

    Yes you are write, I should use mDNS, but it looks complex. So, as it working with DNS I think its ok.
    But anyway I will be looking for mDNS also.
    I am not getting how to do simple ping to "serial_wifi_CC3220SF_LAUNCHXL_tirtos_ccs" project. I tried with IOS, Linux, Windows and Android. So, If you/some-one did it please let me know.
    Thank you
  • Hi,

    Strings devicestr[32] and domainstr[32] are not contained inside any file of 2_30_00_05 SDK. I suppose that this is your modification. But this is not important because domain name in CC3220 is related only at AP mode and you want to use STA mode.

    DNS should work fine with MQTT client, but this solution will be dependent on DNS server at your infrastructure.

    Jan