ESP8266WebServer Response time jumps from 0.03 to 1 second if incoming POST payload is >1024 bytes
- Dominant language
- C++
- Stars
- 16.7k
- Forks
- 13.1k
- PR merge metrics
- No merged PRs in 30d
Description
### Basic Infos
- [X] This issue complies with the [issue POLICY doc](https://github.com/esp8266/Arduino/blob/master/POLICY.md).
- [X] I have read the documentation at [readthedocs](https://arduino-esp8266.readthedocs.io/en/latest) and the issue is not addressed there.
- [X] I have tested that the issue is present in current master branch (aka latest git).
- [X] I have searched the issue tracker for a similar issue.
- [X] If there is a stack dump, I have decoded it.
- [X] I have filled out all fields below.
#### Platform
- Hardware: ESP-12
- Core Version: latest
- Development Env: Arduino IDE
- Operating System: Windows
### Settings in IDE
- Module: Generic ESP8266 Module/Nodemcu v3
- Flash Size: 4MB
### Problem Description
Hello,
I'm trying to post instructions to set LED color values and I've hit a wall. I'm posting a JSON array from my PC and then using that array to set LEDs accordingly on my Nodemcu. I'm using a listener for incoming data `server.on("/command", commandHandler);`
The response time of me posting, receiving, parsing and iterating the JSON array is usually 0.03 seconds. However if I POST to my Nodemcu more than 1024 bytes the response time is always 1 second regardless if I post 1025 bytes or more.
I could send multiple payloads of <1024 bytes however the huge jump from 0.03s to 1s just because of 1 byte makes me wonder if there is some kind of setting I could use to overcome this problem?
Here's what the times look like:
```
Sending 256 bytes
Execution 0.02 s.
Sending 512 bytes
Execution 0.02 s.
Sending 768 bytes
Execution 0.02 s.
Sending 1024 bytes
Execution 0.02 s.
Sending 1280 bytes
Execution 1.00 s.
Sending 1536 bytes
Execution 0.99 s.
Sending 1792 bytes
Execution 1.00 s.
Sending 2048 bytes
Execution 1.00 s.
```
### [MCVE](https://stackoverflow.com/help/mcve) Sketch
```cpp
#include
#include
#include
ESP8266WebServer server(80);
void setup() {
// Initialization
Serial.begin(115200);
WiFi.begin("ssid", "pass");
while (WiFi.status() != WL_CONNECTED) delay(500);
// Listeners
server.on("/command", commandHandler);
server.begin();
}
// POST request to set
void commandHandler() {
DynamicJsonBuffer JSONBuffer;
JsonObject& json = JSONBuffer.parseObject(server.arg("plain"));
if (!json.success()) {
server.send(200, "text/json", "{\"status\":\"Invalid JSON\"}");
return;
}
// LEDs
if(json["leds"]) {
// .. do stuff with leds
}
server.send(200, "text/json", "{\"status\":\"Done\"}");
}
// Main loop
void loop() {
server.handleClient();
}
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.