Page 1 of 2
Maximum size of HTML
Posted:
Thu Mar 23, 2017 8:55 pm
by DonFrench
I noticed that the bottom of some of the pages I send to the client from an ESP8266 were missing in action. It turned out that it was related to the size of the HTML page I was sending. I wrote a simple little program to find out what the maximum length is before truncation occurs, which turns out to be 2916 characters. So has anyone else noticed this and / or have an idea why it is happening or if there is a workaround? I can provide the code if anyone wants to do their own test.
Re: Maximum size of HTML
Posted:
Sun Mar 26, 2017 10:10 pm
by DonFrench
I am surprised I got no replies. Well, someone on another forum informed me that the TCP tx buffer size on the ESP8266 is 2920 bytes, which is 4 more than I found to be the maximum length of an HTML message, so that would seem to be the answer.
Re: Maximum size of HTML
Posted:
Mon Mar 27, 2017 7:13 am
by picstart
The max packet size in TCP is 1460 bytes. The the tx buffer for efficiency needs to be at least twice that or 2920 bytes to allow for one packet to be transmitted while another is being formed.
I don't see how this limits html providing your code allows the radio section of the esp8266 enough cpu cycles to transmit whatever is in it's buffer. Your code can't be blocking on the transmission while you post html to the buffer.
As to the 2916 I suspect since things are on 4 byte boundaries you can't get within 4 bytes of the 2920 maximum
Re: Maximum size of HTML
Posted:
Mon Mar 27, 2017 1:33 pm
by DonFrench
Here is the code. How is it timing related?
Code: Select all#include <ESP8266WiFi.h>
const char WiFiAPPSK[] = "password";
WiFiServer server(80);
String s;
void setup()
{
WiFi.mode(WIFI_AP);
String AP_NameString = "TestHTML";
char AP_NameChar[AP_NameString.length() + 1];
memset(AP_NameChar, 0, AP_NameString.length() + 1);
for (int i = 0; i < AP_NameString.length(); i++)
AP_NameChar[i] = AP_NameString.charAt(i);
WiFi.softAP(AP_NameChar, WiFiAPPSK);
server.begin();
}
void loop()
{
WiFiClient client = server.available();
if (!client) {
return;
}
client.flush();
s = "HTTP/1.1 200 OK\r\n";
s += "Content-Type: text/html\r\n\r\n";
s += "<!DOCTYPE HTML>\r\n<html>\r\n";
s += "<meta name='viewport' content='width=device-width, initial-scale=1'>";
s += "<head> <TITLE> Test HTML max size</TITLE></head><body>";
int str = 0;
for(int i = 0; i < 400; i++){
str = s.length();
String strlength = String(str) + " " + String(i) + "<BR>";
s+= strlength;
}
s +="END";
client.print(s);
client.flush();
delay(1);
}