curl/libcurl networking unreliable? Could it be more modular?
Posted: Thu Apr 27, 2017 11:15 pm
It may be easiest to show an example from a video - with apologies to Neil Kolban who made the video and is an awesome asset to the ESP32 community...
https://www.youtube.com/watch?v=tp4OC_kGMgU.
For those who don't have access to the video, Neil's trying to demonstrate using libcurl to make a RESTFUL api call from the ESP32 to a backend server via HTTPS. It fails the first time but works the second.
Jump to 11:40. He gives up on the first try around 12:09, re-compiles, runs it again and it does work the second time at 12:30.
The problem is I'm seeing the same behavior all the time. It may fail 3-times in a row. Each time I hit the reset button (I'm not re-compiling), and reboot and it fails... Then maybe the forth time it'll work... Putting it in a re-try loop doesn't seem to help - once it's failed, it always seems to need a reboot.
Same thing with HTTP (rather than HTTPS). So, the question is:
Is It possible to reliably make a RESTFUL HTTP or HTTPS calls and get a response on the ESP32?
A small rant as well - I wonder if it's possible to provide examples which are more like libraries? e.g. The wifi examples have multiple inter-related functions and structs and a bunch of stuff in main. Personally, I'd be happy if I could just call a single function (let's call it "get_connected("wifi")") that would make sure wifi is initialized, connected to the AP, has an IP, etc and returns SUCCESS if everything worked or FAILURE otherwise.
https://www.youtube.com/watch?v=tp4OC_kGMgU.
For those who don't have access to the video, Neil's trying to demonstrate using libcurl to make a RESTFUL api call from the ESP32 to a backend server via HTTPS. It fails the first time but works the second.
Jump to 11:40. He gives up on the first try around 12:09, re-compiles, runs it again and it does work the second time at 12:30.
The problem is I'm seeing the same behavior all the time. It may fail 3-times in a row. Each time I hit the reset button (I'm not re-compiling), and reboot and it fails... Then maybe the forth time it'll work... Putting it in a re-try loop doesn't seem to help - once it's failed, it always seems to need a reboot.
Same thing with HTTP (rather than HTTPS). So, the question is:
Is It possible to reliably make a RESTFUL HTTP or HTTPS calls and get a response on the ESP32?
A small rant as well - I wonder if it's possible to provide examples which are more like libraries? e.g. The wifi examples have multiple inter-related functions and structs and a bunch of stuff in main. Personally, I'd be happy if I could just call a single function (let's call it "get_connected("wifi")") that would make sure wifi is initialized, connected to the AP, has an IP, etc and returns SUCCESS if everything worked or FAILURE otherwise.