-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Description
Basic Infos
Hardware
Hardware: wemos D1 mini
Core Version: 2.4.0rc2
Description
If I serve a 8kb webpage from my ESP to a computer in my lan or my mobile phone connected to the lan it works fine. If I activate vpn on the phone and tunnel from the internet to the lan, the website does not load. Sometimes it hangs a while, sometimes it crashes if you retry.
If I limit the packet size in the esp to 1460 and wait 20ms after transmission of each packet it works. See workaround sample code.
When using the sketch, access and it crashes when accessed via vpn. Open /workaround and you get a webpage.
My LAN setup:
internet <-> router1 <-> router2 <-> esp
^
android phone ----VPN ----I
The vpn is tunneled through router1.
Router1 has router2 in its DMZ and has mtu limited to 1400.
Router2 (AVMFritzbox7490) has no mtu setting. They say its automatic.
Settings in IDE
Module: WemosD1mini
Flash Size: 4MB
CPU Frequency: 80Mhz
Flash Mode: ?qio?
Flash Frequency: ?40Mhz?
Upload Using: SERIAL
Reset Method: power cycle
Sketch
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
const char* ssid = "SSID";
const char* password = "*****";
ESP8266WebServer server(80);
void setup(void){
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
if (MDNS.begin("esp8266")) {
Serial.println("MDNS responder started");
}
server.on("/", crashme);
server.on("/workaround", workaround);
server.begin();
server.setContentLength(CONTENT_LENGTH_UNKNOWN);
Serial.println("HTTP server started");
}
void loop(void){
server.handleClient();
}
void crashme()
{
String webpage = "";
for (int i = 0; i<800;i++) webpage +="0123456789";
server.send(200, "text/plain", webpage);
}
void workaround()
{
server.setContentLength(CONTENT_LENGTH_UNKNOWN);
server.sendHeader("Cache-Control","no-cache");
server.sendHeader("Transfer-Encoding","chunked");
server.send(200,"text/plain");
String webpage1 = "";
String webpage2 = "";
String webpage3 = "";
String webpage4 = "";
String webpage5 = "";
for (int i = 0; i<140;i++){ // string needs to be <1460bytes
webpage1 +="0123456789";
webpage2 +="0123456789";
webpage3 +="0123456789";
webpage4 +="0123456789";
webpage5 +="0123456789";
}
server.sendContent( webpage1); delay(20); // delay >= 20ms
server.sendContent( webpage2); delay(20);
server.sendContent( webpage3); delay(20);
server.sendContent( webpage4); delay(20);
server.sendContent( webpage5); delay(20);
server.sendContent("");
}
Debug Messages
messages here