So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By waylander
#76578 Hello esp8266 comunity,

My first post, don't get angry if I do something wrong please ;)

So, I am connecting my ESP8266 to a TCP server running on my PC, the purpose is the board to receive certain strings and float values and to relay them to the serial port without changing them.
It does what's supposed to, however with a long delay - in the range of 9 to 10 seconds.
I am monitoring the traffic via Wireshark, and all looks fine there, the module responds to the server messages almost immediately sending ACK message, but on the serial port, there's a big pause before all messages are sent at once. No lost messages, but my application will be somehow time critical and this issue spoils all the fun.
here the snippet of the code running in loop:

Code: Select allvoid loop() {
  String line = client.readStringUntil('\r');
  Serial.println(line);
}


I also tried inserting
Code: Select allclient.flush()
after the read line, but no change.

Please advice what is that I'm not doing right.

Apart from that it's a great little board and I see lots of projects coming to this one.

Cheers!
User avatar
By waylander
#76609 Hi McChubby007, thanks for your answer.
While I was waiting for my first post to be approved I've done some investigation and the result was I discovered big delay in the readStringUntil() function, not sure why.
I've replaced that line with read() followed by a loop to assemble the string back from the read chars, and now the code works fine - no delay (or at least a very small one). As the Stream library is embedded in the Arduino IDE I could not locate the folder so I could not review the readStringUntil() function code, but as I got solution it's no longer needed.