When you put the instantiation of the ArduinoHttpClient in the loop or in any function, the client often fails to finish the request. It will make the HTTP call, and the server will acknowledge it, but then nothing happens until timeout.
Tested on Nano RP2040 (for WiFiNINA) and Uno R4 WiFi.
It fails for both HTTP and HTTPS, using the steps below:
To reproduce this, using Examples -> SimpleGet:
- change line 12 to #include the correct library for your board (WiFiNINA.h, WiFiS3.h, etc)
- change
serverAddress (line 21) to "www.arduino.cc" or any test server
- change
port (line 22) to 80
- Enter
SECRET_SSID and SECRET_PASS in arduino_secrets.h for your network
- Move line 25,
HttpClient client = etc. to the first line of the loop() function (line 49)
- Upload and watch the results. It will fail at line 50, "Making GET request". It will succeed about 25% of the time, but it will fail in a significant number of cases.
To test HTTPS, change WiFiClient instantiation on line 24 to WiFiSSLClient, and change port to 443.
When you put the instantiation of the ArduinoHttpClient in the loop or in any function, the client often fails to finish the request. It will make the HTTP call, and the server will acknowledge it, but then nothing happens until timeout.
Tested on Nano RP2040 (for WiFiNINA) and Uno R4 WiFi.
It fails for both HTTP and HTTPS, using the steps below:
To reproduce this, using Examples -> SimpleGet:
serverAddress(line 21) to "www.arduino.cc" or any test serverport(line 22) to 80SECRET_SSIDandSECRET_PASSinarduino_secrets.hfor your networkHttpClient client =etc. to the first line of theloop()function (line 49)To test HTTPS, change
WiFiClientinstantiation on line 24 toWiFiSSLClient, and changeportto 443.