Networking, Protocols, and Devices
Upper limit for client.print() string length
Topic: Upper limit for client.print() string length
(Read 8340 times)
Re: Upper limit for client.print() string length
Oct 12, 2017, 08:38 am
I have just been writing a program using ESP8266 WifiClient client.print. And I can verify that the maximum is just under 3000 bytes. I believe the size stated above (2922) is probably correct. I wish it was larger and don't yet know why but will investigate. It does not cause an error to try to print a longer string but it does truncate it so there must be a buffer somewhere that is limiting the size.
It has been found by several people that multiple client.print statements are slow so I build up the string as long as I can before doing the client.print. Doing that, it is reasonably fast. Also, using WiFiClient allows me to leave the connection open for more speed.
Previously, I was using ESP8266WebServer and there is a limit there, too. It is larger. Something around 8KB and it won't go above that. I was not able to find how to do multiple
style commands so I converted to the lower level WifiClient library code. This gives me access to all of the input lines from the browser and I can track browser type, environment and IP address:port.
There is a hierachy here:
ESP8266HTTPUpdateServer (OTA server) is on top of ESP8266WebServer which is on top of WiFiServer.
The program is currently 1600 lines. If someone wants it, I can send it or put it on my web server and post a link. It reads 3 types of temp sensors, also reads Barometric Pressure and Humidity, writes to OLED and SD (history files) and sends out a web page with lots of information including an .svg graphic with 3 symbols and two text lines. If the sensors are missing, it goes on with what it has. I tried to make it not break so easily as some programs.