HTTPClient Library vs Manual Code Response Time?
Posted: Thu Feb 15, 2018 11:31 am
Hi there,
With the ESP8266HTTPClient library using "http.begin()" and "http.GET()" functions the GET requests I am able to read a response very quickly using "payload = http.getString()". However, when using the manual way of connecting with WiFiClient or WiFiClientSecure and sending and receiving the lines manually, it takes up to 5s to read the response from the server. I receive the headers almost immediately after sending, but the actual server response content comes 3-4s after the headers. I use "client.connect()" then use a single "client.print()" line to do a GET request and then use "client.readStringUntil('\n')" to get the headers, then to get the rest of the response. Pretty straightforward and it works, but the responses are slow to come in.
What's the difference here and why is it taking so long doing it manually compared to the HTTPClient functions? Is there something hidden behind the library that I'm missing when doing it manually?
Thanks!
With the ESP8266HTTPClient library using "http.begin()" and "http.GET()" functions the GET requests I am able to read a response very quickly using "payload = http.getString()". However, when using the manual way of connecting with WiFiClient or WiFiClientSecure and sending and receiving the lines manually, it takes up to 5s to read the response from the server. I receive the headers almost immediately after sending, but the actual server response content comes 3-4s after the headers. I use "client.connect()" then use a single "client.print()" line to do a GET request and then use "client.readStringUntil('\n')" to get the headers, then to get the rest of the response. Pretty straightforward and it works, but the responses are slow to come in.
What's the difference here and why is it taking so long doing it manually compared to the HTTPClient functions? Is there something hidden behind the library that I'm missing when doing it manually?
Thanks!