8266 Wi-Fi problem

A very unusual error for me anyway. Happens in both platform I/O and Arduino
the code compiles with no errors and runs locally within your home subnet for me that is 192.168.1.X
I have setup my router for Port forwarding and checked most of the obvious things.
One interesting aspect is if I run on an earlier version of the Arduino board manager 2.4.0 the program runs fine from a remote site if I upgrade to version 2.4.0 R2 I experience the same error but I cannot connect but locally it works fine.

Very strange I do not know where else to post if this is the incorrect area.
If anyone could show me what I’m doing wrong I would much appreciate it.
Thanking you for your help in advance

#include <ArduinoOTA.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

const char* ssid = "BTHub5-RKSM";
const char* password = ;

ESP8266WebServer server(80);

const int led = LED_BUILTIN;

IPAddress ip(192, 168, 1, 202);  // ip of Client
IPAddress gateway(192,168,1,254);           // gateway of your network
IPAddress subnet(255,255,255,0);
IPAddress dns(192, 168, 1, 254);
unsigned long delays=2000;

String  theme = "darkly";
long Day=0;
int Hour =0;
int Minute=0;
int Second=0;
int HighMillis=0;
int Rollover=0;
String bmp_stv1,bmp_spv1,bmp_sav1;       //BMP sensor string values
float bmp_tv1,bmp_tpv1,bmp_tlv1,bmp_thv1; //BMP temperature sensors float values
float bmp_hv1,bmp_hpv1,bmp_hlv1,bmp_hhv1; //BMP humidity sensor float values
float bmp_av1,bmp_apv1,bmp_alv1,bmp_ahv1; //BMP atmospheric sensor float values
String dht_stv1,dht_shv1;               //DHT22 sensor string values
float dht_tv1,dht_tpv1,dht_tlv1,dht_thv1; //DHT22 temperature sensor float values
float dht_hv1,dht_hpv1,dht_hlv1,dht_hhv1; //DHT22 humidity sensor float values
String lightsv1,lightsv2,lightsv3,lightsv4,lightsv5;
int lightv1,lightv2,lightv3,lightv4,lightv5;
int lightpv1,lightpv2,lightpv3,lightpv4,lightpv5;
String  etatGpio[5] = {"HOME","Page2","Page3","Page4","Page5"};
const uint8_t GPIOPIN[5] = {1,2,3,4,5};
WiFiClient client;
String getwebPage1();


void handleRoot() {
  digitalWrite(led, 1);
  server.send ( 200, "text/html", getwebPage1() );
//getwebPage1();
  digitalWrite(led, 0);
}

void handleNotFound(){
  digitalWrite(led, 1);
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET)?"GET":"POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i=0; i<server.args(); i++){
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  server.send(404, "text/plain", message);
  digitalWrite(led, 0);
}

void setup(void){
  pinMode(led, OUTPUT);
  digitalWrite(led, 0);
  Serial.begin(115200);

  Serial.println("Booting");
  WiFi.config(ip, dns, gateway, subnet);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("Connection Failed! Rebooting...");
    delay(5000);
    ESP.restart();
  }

  if (MDNS.begin("esp8266")) {
    Serial.println("MDNS responder started");
  }

  server.on("/", handleRoot);

  server.on("/inline", [](){
    server.send(200, "text/plain", "this works as well");
  });

  server.onNotFound(handleNotFound);

  ArduinoOTA.onStart([]() {
    String type;
    if (ArduinoOTA.getCommand() == U_FLASH)
      type = "sketch";
    else // U_SPIFFS
      type = "filesystem";

    // NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
    Serial.println("Start updating " + type);
  });
  ArduinoOTA.onEnd([]() {
    Serial.println("\nEnd");
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  });
  ArduinoOTA.onError([](ota_error_t error) {
    Serial.printf("Error[%u]: ", error);
    if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
    else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
    else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
    else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
    else if (error == OTA_END_ERROR) Serial.println("End Failed");
  });
  ArduinoOTA.begin();
  Serial.println("Ready");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  server.begin();
  Serial.println("HTTP server started");
  pinMode(2,OUTPUT);

}

void loop(void){
  ArduinoOTA.handle();
  server.handleClient();

digitalWrite(led,0);
digitalWrite(2,0);
for (int i=0; i <=10; i++) {
ArduinoOTA.handle();
server.handleClient();
delay(50);}

digitalWrite(led,1);
digitalWrite(2,1);
for (int i=0; i <=10; i++) {
ArduinoOTA.handle();
server.handleClient();
delay(50);}

}

String getwebPage1(){
 // Return a string containing the HTML code of the page
  String page = "<html charset=UTF-8><head><meta http-equiv='refresh' content='15' name='viewport' content='width=device-width, initial-scale=1'/>";
  page += "<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script><script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js'></script>";

    page += "<link href='https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/";
    page += theme;
    page += "/bootstrap.min.css' rel='stylesheet'>";
  page += "<title>ESP8266 Demo </title></head><body>";
  page += "<div class='container-fluid'>";
  page +=   "<div class='row'>";
  page +=     "<div class='col-md-12'>";
  page +=       "<h3>Monitoring Service ESP8266 ";
  page +=       "&nbsp;&nbsp;&nbsp;&nbsp;";
  page +=       "Up Time: ";
  page +=       Day;
  page +=       " Days ";
  page +=       Hour;
  page +=       " Hours ";
  page +=       Minute;
  page +=       " Minutes ";
  page +=       Second;
  page +=       " Seconds ";
  page +=       "</h1>";
  page +=       "<h3></th><th>Mini station Conservatory</h3>";
  page +=       "<ul class='nav nav-pills'>";
  page +=         "<li class='active'>";
  page +=           "<a href='#'> <span class='badge pull-right'>";
  page +=           dht_tv1;
  page +=           "</span> Temperature</a>";
  page +=           "<li class='active'>";
  page +=         "</li><li>";
  page +=           "<li class='active'>";
  page +=           "<a href='#'> <span class='badge pull-right'>";
  page +=           dht_hv1;
  page +=           "</span> Humidity</a>";
  page +=         "</li><li>";
  page +=           "<li class='active'>";
  page +=           "<a href='#'> <span class='badge pull-right'>";
  page +=           bmp_hv1;
  page +=           "</span> Atmospheric Pressure</a>";//*************
  page +=         "</li><li>";
  page +=           "<li class='active'>";
  page +=           "<a href='#'> <span class='badge pull-right'>";
  page +=           lightv1;
  page +=           "</span> Light Value</a></li>";
  page +=           "</ul>";
  page +=           "<table class='table'>";  // Chart of readings
  page +=           "<thead><tr class='active'><th>Sensor<th>Measurement<th>Value<th>PV<th>Low<th>High</tr></thead>";
  page +=           "<tbody>";  // Table content
  page +=           "<tr><td>DHT22</td><td>Temperature</td><td>"; // First line : temperature
  page +=             dht_tv1;
  page +=             "&deg;C</td><td>";
  page +=             dht_tpv1;
  page +=            "<td>";
  page +=             dht_tlv1;
  page +=             "<td>";
  page +=             dht_thv1;
  page +=             "</td></td>";
  page +=           "<tr><td>DHT22</td><td>Humidity</td><td>"; // 2nd line : humidity *************************<tr class='active'>
  page +=             dht_hv1;
  page +=             "%</td><td>";
  page +=             dht_hpv1;
  page +=             "<td>";
  page +=             dht_hlv1;
  page +=           "<td>";
  page +=             dht_hhv1;

  page +=             "</td></tr>";
  page +=             "<tr><td>BMP280</td><td>Temperature</td><td>"; // 3th line : atmospheric pressure
  page +=             bmp_tv1;
  page +=             "&deg;C</td><td>";
  page +=             bmp_tpv1;
  page +=             "<td>";
  page +=             bmp_tlv1;
  page +=            "<td>";
  page +=             bmp_thv1;

  page +=             "</td></tr>";
  page +=             "<tr><td>BMP280</td><td>Atmospheric Pressure</td><td>"; // 3th line : atmospheric pressure
  page +=             bmp_hv1;
  page +=             "mbar</td><td>";
  page +=             bmp_hpv1;
  page +=             "<td>";
  page +=             bmp_hlv1;
  page +=            "<td>";
  page +=             bmp_hhv1;

/*
  page +=             "</td></tr>";
  page +=             "<tr><td>BMP280</td><td>Approximate altitude</td><td>"; // 3th line : atmospheric pressure
  page +=             bmp_av1;
  page +=             "M</td><td>";
  page +=             bmp_apv1;
  page +=             "<td>";
  page +=             bmp_alv1;
  page +=            "<td>";
  page +=             bmp_ahv1;
*/
  page +=             "</td></tr>";
  page +=             "<tr><td>Photoresistor</td><td>Light </td><td>"; // 4th line : Light
  page +=             lightv1;
  page +=             "%<td>";
  page +=             lightpv1;
  page +=             " %</td><td>";
  page +=             "</tbody></table></div></div>";
  page +=             "<div class='row'>";

  page +=             "<div class='container'>";
  page +=             "</body></html>";
  page +=             "<form action='/' method='POST'><button type='button submit'name='1' value='HOME' class='btn btn-info'><span class='badge'>";
  page +=             etatGpio[0];
  page +=             "</span></button>";
  page +=             "<form action='/' method='POST'><button type='button submit'name='2' value='Page2' class='btn btn-primary'> <span class='badge'>";
  page +=             etatGpio[1];
  page +=             "</span></button>";
  page +=             "<form action='/' method='POST'><button type='button submit'name='3' value='Page3' class='btn btn-success'><span class='badge'>";
  page +=             etatGpio[2];
  page +=             "</span></button>";
  page +=             "<form action='/' method='POST'><button type='button submit'name='4' value='Page4' class='btn btn-warning'><span class='badge'>";
  page +=             etatGpio[3];
  page +=             "</span></button>";
  page +=             "<form action='/' method='POST'><button type='button submit'name='5' value='Page5' class='btn btn-danger'><span class='badge'>";
  page +=             etatGpio[4];
  page +=             "</span></button>";
  page +=             "</div><div>";
  return page;
}

I do not know if this has anything to do it but it seems to be something to do with the string size.
Playing around I cut the size of the string in half and it works I can see it on a remote site.
It’s their a size limit on the string? If so how do I make it longer//bigger.
Do I have to split up the strings and send part a and then part B.

Probably a wild goose chase plus what I just found. I will now go off and look for maximum string size

Just found this
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

So I presume that there is no way around it strange that it works well with the earlier version 2.4.0 but not the newer version 2.4.0 r2

I suspect one of the experts will come on soon and tell me what I’m doing wrong, and it has nothing to do with string size.
And why does it work perfectly if you are on the local network but not on remote network, what is the difference.

Now totally confused I think I will have to wait for some help.
Please

Very weird indeed. I have two main optimization possibilites:

  • Current you are having a function String getwebPage1() which computes a new (huge) String object and returns it by value. Returning by value will create a copy of your already huge string and then destroy the local variable. I have re-written it to use the C++ feature of a reference, i.e. void getwebPage1(String& page). This does not make a copy at the end and saves memory and computation time. I doubt however that this is a problem, the ESP8266 on the Arduino Framework has like 40 KB of free heap space, with those strings you are unlikely to run out of memory. This method might still not be maximally efficient as it uses “+=” operator to append to the String, which might make a copy of the current String and append it.
  • You are using delay in your loop for blinking LEDs. I’ve re-written this to use “blink without delay” technique (see https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay). Now there aren’t any delay calls which might block execution or something.
  • careful with Wifi.config, the argument order is changed there (ESP-8266 WiFi.config(ip, gateway, subnet); · Issue #2371 · esp8266/Arduino · GitHub). In my tests I commented it out, it drew it’s IP via DHCP and everything worked nicely. You can also use your router to configure a DHCP reservation for the ESP’s MAC address so that it always gets the same IP assigned.

Otherwise I don’t see anything majorly wrong in your code that causes the page to not load over an external device through port forwarding.

Try:

#include <Arduino.h>
#include <ArduinoOTA.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

const char* ssid = "**CHANGE**";
const char* password = "**CHANGE**";

ESP8266WebServer server(80);

const int led = LED_BUILTIN;

IPAddress ip(192, 168, 1, 202);  // ip of Client
IPAddress gateway(192,168,1,254);           // gateway of your network
IPAddress subnet(255,255,255,0);
IPAddress dns(192, 168, 1, 254);
unsigned long delays=2000;

String  theme = "darkly";
long Day=0;
int Hour =0;
int Minute=0;
int Second=0;
int HighMillis=0;
int Rollover=0;
String bmp_stv1,bmp_spv1,bmp_sav1;       //BMP sensor string values
float bmp_tv1,bmp_tpv1,bmp_tlv1,bmp_thv1; //BMP temperature sensors float values
float bmp_hv1,bmp_hpv1,bmp_hlv1,bmp_hhv1; //BMP humidity sensor float values
float bmp_av1,bmp_apv1,bmp_alv1,bmp_ahv1; //BMP atmospheric sensor float values
String dht_stv1,dht_shv1;               //DHT22 sensor string values
float dht_tv1,dht_tpv1,dht_tlv1,dht_thv1; //DHT22 temperature sensor float values
float dht_hv1,dht_hpv1,dht_hlv1,dht_hhv1; //DHT22 humidity sensor float values
String lightsv1,lightsv2,lightsv3,lightsv4,lightsv5;
int lightv1,lightv2,lightv3,lightv4,lightv5;
int lightpv1,lightpv2,lightpv3,lightpv4,lightpv5;
String  etatGpio[5] = {"HOME","Page2","Page3","Page4","Page5"};
const uint8_t GPIOPIN[5] = {1,2,3,4,5};
WiFiClient client;

/* Use a string reference to avoid copying */
void getwebPage1(String& outString);

void handleRoot() {
	digitalWrite(led, 1);
	String webPage = "";
	//Compute the webPage in the string, use by reference.
	getwebPage1(webPage);
	// The function can use a const String&, so no duplicating done -- memory friendly!
	server.send ( 200, "text/html",  webPage);
	//getwebPage1();
	digitalWrite(led, 0);
}

void handleNotFound(){
	digitalWrite(led, 1);
	String message = "File Not Found\n\n";
	message += "URI: ";
	message += server.uri();
	message += "\nMethod: ";
	message += (server.method() == HTTP_GET)?"GET":"POST";
	message += "\nArguments: ";
	message += server.args();
	message += "\n";
	for (uint8_t i=0; i<server.args(); i++){
		message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
	}
	server.send(404, "text/plain", message);
	digitalWrite(led, 0);
}

void setup(void){
	pinMode(led, OUTPUT);
	digitalWrite(led, 0);
	Serial.begin(115200);

	Serial.println("Booting");
	WiFi.config(ip, dns, gateway, subnet);
	WiFi.mode(WIFI_STA);
	WiFi.begin(ssid, password);
	while (WiFi.waitForConnectResult() != WL_CONNECTED) {
		Serial.println("Connection Failed! Rebooting...");
		delay(5000);
		ESP.restart();
	}

	if (MDNS.begin("esp8266")) {
		Serial.println("MDNS responder started");
	}

	server.on("/", handleRoot);

	server.on("/inline", [](){
		server.send(200, "text/plain", "this works as well");
	});

	server.onNotFound(handleNotFound);

	ArduinoOTA.onStart([]() {
		String type;
		if (ArduinoOTA.getCommand() == U_FLASH)
			type = "sketch";
		else // U_SPIFFS
			type = "filesystem";

		// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
		Serial.println("Start updating " + type);
	});
	ArduinoOTA.onEnd([]() {
		Serial.println("\nEnd");
	});
	ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
		Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
	});
	ArduinoOTA.onError([](ota_error_t error) {
		Serial.printf("Error[%u]: ", error);
		if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
		else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
		else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
		else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
		else if (error == OTA_END_ERROR) Serial.println("End Failed");
	});
	ArduinoOTA.begin();
	Serial.println("Ready");
	Serial.print("IP address: ");
	Serial.println(WiFi.localIP());

	server.begin();
	Serial.println("HTTP server started");
	pinMode(2,OUTPUT);

}

/* Now uses the technique "blink without delay" to avoid blocking anything!
 * delay() might block the execution of something important like the WiFi stack.
 * Just remember the last time we did something and look at how much time has passed.
 * */
unsigned long lastActionTime = 0;
const unsigned long blinkInterval = 500; /* milliseconds */

void loop(void){
	ArduinoOTA.handle();
	server.handleClient();

	//Is it time to do something?
	if(millis() - lastActionTime >= blinkInterval) {
		//Yes, toggle the two pins.
		//Uses "XOR 1" trick to toggle the value,
		//using "x XOR 1" with x either 0 or 1 will invert
		//the value of x (0 -> 1, 1 -> 0).
		digitalWrite(led, digitalRead(led) ^ 1);
		digitalWrite(2, digitalRead(2) ^1);
		//remember that we did something
		lastActionTime = millis();
	}
}

/* Do not create and return a new "String" object by value, instead use a reference to an already existing variable. C++ ftw! */
void getwebPage1(String& page) {
	// Return a string containing the HTML code of the page
	page = "<html charset=UTF-8><head><meta http-equiv='refresh' content='15' name='viewport' content='width=device-width, initial-scale=1'/>";
	page += "<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script><script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js'></script>";

	page += "<link href='https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/";
	page += theme;
	page += "/bootstrap.min.css' rel='stylesheet'>";
	page += "<title>ESP8266 Demo </title></head><body>";
	page += "<div class='container-fluid'>";
	page +=   "<div class='row'>";
	page +=     "<div class='col-md-12'>";
	page +=       "<h3>Monitoring Service ESP8266 ";
	page +=       "&nbsp;&nbsp;&nbsp;&nbsp;";
	page +=       "Up Time: ";
	page +=       Day;
	page +=       " Days ";
	page +=       Hour;
	page +=       " Hours ";
	page +=       Minute;
	page +=       " Minutes ";
	page +=       Second;
	page +=       " Seconds ";
	page +=       "</h1>";
	page +=       "<h3></th><th>Mini station Conservatory</h3>";
	page +=       "<ul class='nav nav-pills'>";
	page +=         "<li class='active'>";
	page +=           "<a href='#'> <span class='badge pull-right'>";
	page +=           dht_tv1;
	page +=           "</span> Temperature</a>";
	page +=           "<li class='active'>";
	page +=         "</li><li>";
	page +=           "<li class='active'>";
	page +=           "<a href='#'> <span class='badge pull-right'>";
	page +=           dht_hv1;
	page +=           "</span> Humidity</a>";
	page +=         "</li><li>";
	page +=           "<li class='active'>";
	page +=           "<a href='#'> <span class='badge pull-right'>";
	page +=           bmp_hv1;
	page +=           "</span> Atmospheric Pressure</a>";//*************
	page +=         "</li><li>";
	page +=           "<li class='active'>";
	page +=           "<a href='#'> <span class='badge pull-right'>";
	page +=           lightv1;
	page +=           "</span> Light Value</a></li>";
	page +=           "</ul>";
	page +=           "<table class='table'>";  // Chart of readings
	page +=           "<thead><tr class='active'><th>Sensor<th>Measurement<th>Value<th>PV<th>Low<th>High</tr></thead>";
	page +=           "<tbody>";  // Table content
	page +=           "<tr><td>DHT22</td><td>Temperature</td><td>"; // First line : temperature
	page +=             dht_tv1;
	page +=             "&deg;C</td><td>";
	page +=             dht_tpv1;
	page +=            "<td>";
	page +=             dht_tlv1;
	page +=             "<td>";
	page +=             dht_thv1;
	page +=             "</td></td>";
	page +=           "<tr><td>DHT22</td><td>Humidity</td><td>"; // 2nd line : humidity *************************<tr class='active'>
	page +=             dht_hv1;
	page +=             "%</td><td>";
	page +=             dht_hpv1;
	page +=             "<td>";
	page +=             dht_hlv1;
	page +=           "<td>";
	page +=             dht_hhv1;

	page +=             "</td></tr>";
	page +=             "<tr><td>BMP280</td><td>Temperature</td><td>"; // 3th line : atmospheric pressure
	page +=             bmp_tv1;
	page +=             "&deg;C</td><td>";
	page +=             bmp_tpv1;
	page +=             "<td>";
	page +=             bmp_tlv1;
	page +=            "<td>";
	page +=             bmp_thv1;

	page +=             "</td></tr>";
	page +=             "<tr><td>BMP280</td><td>Atmospheric Pressure</td><td>"; // 3th line : atmospheric pressure
	page +=             bmp_hv1;
	page +=             "mbar</td><td>";
	page +=             bmp_hpv1;
	page +=             "<td>";
	page +=             bmp_hlv1;
	page +=            "<td>";
	page +=             bmp_hhv1;

	/*
  page +=             "</td></tr>";
  page +=             "<tr><td>BMP280</td><td>Approximate altitude</td><td>"; // 3th line : atmospheric pressure
  page +=             bmp_av1;
  page +=             "M</td><td>";
  page +=             bmp_apv1;
  page +=             "<td>";
  page +=             bmp_alv1;
  page +=            "<td>";
  page +=             bmp_ahv1;
	 */
	page +=             "</td></tr>";
	page +=             "<tr><td>Photoresistor</td><td>Light </td><td>"; // 4th line : Light
	page +=             lightv1;
	page +=             "%<td>";
	page +=             lightpv1;
	page +=             " %</td><td>";
	page +=             "</tbody></table></div></div>";
	page +=             "<div class='row'>";

	page +=             "<div class='container'>";
	page +=             "</body></html>";
	page +=             "<form action='/' method='POST'><button type='button submit'name='1' value='HOME' class='btn btn-info'><span class='badge'>";
	page +=             etatGpio[0];
	page +=             "</span></button>";
	page +=             "<form action='/' method='POST'><button type='button submit'name='2' value='Page2' class='btn btn-primary'> <span class='badge'>";
	page +=             etatGpio[1];
	page +=             "</span></button>";
	page +=             "<form action='/' method='POST'><button type='button submit'name='3' value='Page3' class='btn btn-success'><span class='badge'>";
	page +=             etatGpio[2];
	page +=             "</span></button>";
	page +=             "<form action='/' method='POST'><button type='button submit'name='4' value='Page4' class='btn btn-warning'><span class='badge'>";
	page +=             etatGpio[3];
	page +=             "</span></button>";
	page +=             "<form action='/' method='POST'><button type='button submit'name='5' value='Page5' class='btn btn-danger'><span class='badge'>";
	page +=             etatGpio[4];
	page +=             "</span></button>";
	page +=             "</div><div>";
	return;
}

Thank you ever so much for looking into the problem and suggesting a different way of coding. I have tried your example and again the same problem appears, on the local network no problem at all, on the remote nothing at all.
I know it’s asking a lot from you but did you managed to get it to work from a non-local network machine as I say it works perfectly on the local machine.
if anybody has any other suggestions I’ve been more than happy to try them.
Also as you can see from the code there is usually five pages
as a test I have compiled the full version of the code to meathome2017.hopto.org this one works reasonably well but is on the old build version 2.4.0
meathome2017.hoptp.org:8082 looks at the new version and as you see nothing.

Thank you again for all your hard work and please if you have any more suggestions I could sure do with them

Unfortunately I’m unable to test this with port forwarding and an external device since I don’t own the router in my network. I thought that maybe better memory allocation strategies and no delay() would do the trick.

If this does change with the Arduino-ESP8266 Framework version that is most interesting. I suggest you open a Github issue on GitHub - esp8266/Arduino: ESP8266 core for Arduino and restate your problem and the version in which it works and in which it doesn’t. Those people can help you best.