This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Basic http get example

Hello,

We are working with the nrf 9160 dk.

We need to use internet connectivity to send an http get and post to a remote server.

We want to utilize the NB-IoT modem on the board. 

As it stands now, can get connected to the network but we cannot send a get or post to the remote server.

Kindly let us know if there is a configuration or a example code we can use to achieve this.

Thanks and regards

  • Hi,

    smauelGIS said:
    Did you use CONFIG_LTE_NETWORK_MODE_NBIOT=y for the test with NB1?

    Yes, I tested with this config entry.

    smauelGIS said:
    It still hangs infact at getaddrinfo() procedure. we get an error code 60.

    This indicates that the network you're connected to does not provide a DNS service (getaddrinfo cannot resolve the hostname), or that its currently unavailable.

    You can manually resolve the hostname at your end, and input that as a string, like this "127.0.0.1".

     

    Kind regards,

    Håkon

  • Thanks for the response;

    So when we do my the manual resolving as you suggested; for example for google.com ("216.58.208.174"), getaddinfo() is ok, but we still get stuck at connect(), with an error "connect() failed, err: 60".

    As you may note, this was the first error I sent to you at the start of this thread! We did manual resolving of google's hostname.

    Please is there another config we need to do? Or a hardware plug we need to push?

    Kindly help

    Regards.

  • Hi,

     

    I tested setting the same IP in https_client sample, and had no problems connecting afterwards. However; I am on a completely different network than you.

    smauelGIS said:
    Please is there another config we need to do? Or a hardware plug we need to push?

    The behavior you see is highly likely inherited from the network that you are connecting to.

    Have you tested if TCP works at all in your current network?

    Did you try mqtt_simple, where you set the IP manually in prj.conf? mqtt.eclipse.org currently resolves to 137.135.83.217, so that would be:

    CONFIG_MQTT_BROKER_HOSTNAME="137.135.83.217"

     

    If that fails, try an UDP based sample, like this one (Change define NTP_HOST to 129.240.2.6):

    https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/ntp/src/main.c

     

    Kind regards,

    Håkon

  • Have you tested if TCP works at all in your current network?

    could you provide may be an AT command to test a TCP connection? I tried to get an AT command for a ping, but i could not find one at the reference site.

    the mqtt_sample even with the resolved IP does not work.

    I will try the UDP sample you sent.

    Thanks and Regards.

    P.S kindly help with a tool to check if TCP works on a network.

    Regards

  • Hi,

     

    The AT commands do not include any IP related commands, unfortunately. UDP and TCP tests must be performed on a socket level.

     

    Kind regards,

    Håkon

1 2 3