while(client.connected() || client.available()){
if (client.available()) {
response += client.readStringUntil('\r\n');
// this reads each payload line, but pauses for 50+seconds after Jason payload .
}
}
Output from .ino attached
millis after connect: 14153 : 14153 : 52
trying....GET /get/latest/dweet/for/myThing HTTP/1.1
Host: dweet.io
Connection: close
Receive Response:
millis in receive loop: 14194 : 41 : 93 : HTTP/1.1 200 OK
which library? some could take some time in connected(). replace if (client.available()) { with while (client.available()) {
readStringUntil takes a char as parameter, not two chars. it waits a second for the next character, if terminator is not in input. you loose seconds there.
I found if I use client.available() to control things, I need to wait for data to start flowing before going into the while loop. This has improved performance 10x but still takes 5 seconds. I guess that's all i'm going to get out of this tiny WEMO d2.
//delay up to 2 seconds
for (x=0; x < 20; x++) {
if (client.available())
break;
delay(100);
}
KenLajoie:
Is there another way to know the end of the data? eof? It seems my pause is caused by not finding the until character on the final chunk of data.
I'm curious how a browser does this.
browser reads the content-length header or chunked encoding or timeout or tcp connection closed