http_client network error on thingy91

Hello,

I am trying to use http requests on Thingy91 and therefore I tried with the sample from zephyr/samples/net/sockets/http_client.

I can build the project without any problem but when I try to run it, I get the following error when I open a putty terminal:

I did not change anything in the code, and I was supposing it was not a network problem since I activated my SIM card and I can run the asset_tracker and see the data in nrFcloud without any issue.

I am using the nrfConnectSDK 2.0.0, and the SIM is from twilio.

Best regards,

C

Parents
  • Hello Carole, 

    rupcar said:
    Actually, for now I just edited the https_client so that what was in the main() is in a new function called network_connection().

    You have placed network_connection() and its content into a while(1) loop, which now explains the behaviour you are facing. 

    Please revert these changes immediately, the function calls inside the main() function of the HTTPS Client are not supposed to be called more than once! 

    The modem is not designed for being initialised/enabled and shutdown during each iteration of the main function. That will wear out its non-volatile memory. Referring to the CAUTION part in +CFUN. 

    CFUN=0 causes writing to NVM. When using CFUN=0, take NVM wear into account. 


    The same applies to sockets, they are not intended to be opened and closed during each iteration neither. 

    Additionally, it might be good to know that all samples within the nRF Connect SDK are based on the Zephyr framework, which is a RTOS. This implies that a main() function always is a scheduled thread. Referring to the Threads and Scheduling documentation for more information. 

    Cheers, 

    Markus 

Reply
  • Hello Carole, 

    rupcar said:
    Actually, for now I just edited the https_client so that what was in the main() is in a new function called network_connection().

    You have placed network_connection() and its content into a while(1) loop, which now explains the behaviour you are facing. 

    Please revert these changes immediately, the function calls inside the main() function of the HTTPS Client are not supposed to be called more than once! 

    The modem is not designed for being initialised/enabled and shutdown during each iteration of the main function. That will wear out its non-volatile memory. Referring to the CAUTION part in +CFUN. 

    CFUN=0 causes writing to NVM. When using CFUN=0, take NVM wear into account. 


    The same applies to sockets, they are not intended to be opened and closed during each iteration neither. 

    Additionally, it might be good to know that all samples within the nRF Connect SDK are based on the Zephyr framework, which is a RTOS. This implies that a main() function always is a scheduled thread. Referring to the Threads and Scheduling documentation for more information. 

    Cheers, 

    Markus 

Children
  • Hello,

    Thank you again for the answer!

    I revert those changes and I don't get the err 116 coming from connect() anymore.

    But 115 from getAddrInfo() is still there... I am guessing then it is more a network problem? it is, is there a way to choose which network provider's it connects to and see how strong the connection is ?

    Also, I had my while() loop because I intent to do a POST request every hour (to a database). What is then the best way to proceed ?

    Carole

Related