Connect to nRFCloud using CoAP over NB-IoT does not work

Hello

I am trying to connect the nRF9160 -DK board to nRFCloud using CoAP protocol. I have written an application for this case. I tested my application with two different SIM Cards.
One of the sim cards supports LTE connection and the other one supports only NB-IoT. Using the LTE SIM card I can successfully connect, but using the other SIM Card that only supports NB-IoT can not connect to nRFCloud using CoAP.

On the following screen shot is the LOGS of the system using the NB-IoT connection.
The Error occurs when I call the nrf_cloud_coap_connect("1.2.3"); function in my code.

In case I use the LTE connection, using the first sim card, I have a successful connection to the nRFCloud.

To test if there is something missing in my code, required for NB-IoT connections I also used the nrf_cloud_multi_service example from nordic, using the overlay_coap.conf to enable the CoAP protocol.
In this case I have the same results as using my code, described above. With LTE connection I can connect to nRFCloud, but with NB-IoT connection it does not connect.
In the following picture is the LOGS from the  nrf_cloud_multi_service example using NB-IoT connection.

As far as I know the CoAP can work using NB-IoT connection. Is there any other requirements to connect to nRFCloud using CoAP via a NB-IoT connection? What are the possible reasons for this matter?

Thank you in advance

Parents
  • At least in general, the only difference using CoAP with LTE-M or NB-IoT I know are the retransmission timeouts, though the RTT with NB-IoT is slightly larger.

    You decided to "hide the ip-addresses", which is the base of ip-traffic. So I'm not sure, if analyzing the leftovers makes sense. For me it looks like the modem get "ipv6 only", but the dns-lookup for "coap.nrfcloud.com" returns ipv4. You may need to adapt the lookup call to return ipv6.

Reply
  • At least in general, the only difference using CoAP with LTE-M or NB-IoT I know are the retransmission timeouts, though the RTT with NB-IoT is slightly larger.

    You decided to "hide the ip-addresses", which is the base of ip-traffic. So I'm not sure, if analyzing the leftovers makes sense. For me it looks like the modem get "ipv6 only", but the dns-lookup for "coap.nrfcloud.com" returns ipv4. You may need to adapt the lookup call to return ipv6.

Children
  • Hello

    I took again a screenshot with the log messages.
    I also have tried the following configs:

    CONFIG_NET_IPV6=n
    CONFIG_NET_IPV4=y
    CONFIG_NET_IPV6=y
    CONFIG_NET_IPV4=n

    So to enable only IPV4 or IPV6 and I had the same results. I always connect via LTE but not with NB-IoT.

    Following is the screenshot with the IP address this time.

    Thank you

  • "PDN type IPv6 only allowed"

    I guess, you need to provide a modem trace to see, what causes the failure in your case.

  • Hello

    I have upload two screenshots with the modem trace of the system.
    As I can see the modem gets IPv6.

    I looked more on the IP issue and I found out that my provider only gives IPV6.

    Looking more into it I found the following.
    The error message from nrfcloud comes from the function:
    int nrf_cloud_coap_connect(const char * const app_ver)


    More specifically inside above function when it calls the:
    err = connect(sock, (struct sockaddr *)&server, sizeof(struct sockaddr_in));

    (This function can be found inside nrf_cloud_coap_transport.c file.)

    It looks like the sockaddr_in only accepts ipv4 as follows

    struct sockaddr_in {
        sa_family_t     sin_family;    /* AF_INET      */
        uint16_t        sin_port;      /* Port number  */
        struct in_addr      sin_addr;      /* IPv4 address */
    };
     
    Also in prj.conf I tried the
    CONFIG_NRF_CLOUD_IPV6=y
    but it does not accept it because it supports only NRF_CLOUD_MQTT.

    So, it looks like the nrf cloud coap library only supports ipv4. Only the nrf cloud mqtt can work with both ipv4 and ipv6. 

    I have also found at the coap documentation that the coap is compatible with ipv4 and ipv6, but the nrfcloud coap seems that it does not.

    Do you think that this is the issue?

    If this is the case, is there any way to overcome this since it is stated that the coap supports both ipv4 and ipv6?

  • I looked more on the IP issue and I found out that my provider only gives IPV6.

    That was also my guess in my first comment.

    Do you think that this is the issue?

    nrf_cloud_transport.c (MQTT?):

        struct addrinfo hints = {
            .ai_family = NRF_CLOUD_AF_FAMILY,
            .ai_socktype = SOCK_STREAM
        };

        err = getaddrinfo(NRF_CLOUD_HOSTNAME, NULL, &hints, &result);

    nrf_cloud_coap_transport.c (CoAP):

        struct addrinfo hints = {
            .ai_family = AF_INET,
            .ai_socktype = SOCK_DGRAM
        };
        char ipv4_addr[NET_IPV4_ADDR_LEN];

        LOG_DBG("Looking up server %s", CONFIG_NRF_CLOUD_COAP_SERVER_HOSTNAME);
        err = getaddrinfo(CONFIG_NRF_CLOUD_COAP_SERVER_HOSTNAME, NULL, &hints, &result);

    Yeap, looks like Nordic does consider IPv6 only half the way for CoAP ;-).

    The good point maybe, that they already assign an IPv6 address to the DNS entry:

    nslookup coap.nrfcloud.com

    Non-authoritative answer:
    Name:    coap.nrfcloud.com
    Address: 34.234.231.237
    Name:    coap.nrfcloud.com
    Address: 35.168.102.27
    Name:    coap.nrfcloud.com
    Address: 3.84.64.178
    Name:    coap.nrfcloud.com
    Address: 2600:1f18:56ff:3d00:a:6:8600:0
    Name:    coap.nrfcloud.com
    Address: 2600:1f18:56ff:3d02:a:41:cc00:0
    Name:    coap.nrfcloud.com
    Address: 2600:1f18:56ff:3d01:a:3e:5200:0

    So, lets see, what an Nordic Engineer answers. Maybe it just needs to be fixed, maybe be the "gap" for IPv6 in the implementations used by Nordic is larger and therefore the getaddrinfo didn't go for IPv6.

  • That was also my guess in my first comment.

    What you said on your first commend helped me to focus on the ip version issue and move closer to find the problem. 
    Thank you for your help!

    Yeap, looks like Nordic does consider IPv6 only half the way for CoAP ;-).

    Yes, this might me the case.

    Hopefully we might me able to get more help solving this issue.

Related