Wemos D1 Wifi disconect webserver

[Hi!

I had this board and I upload a simple program for LED control.

When I turn it ON, it work fine and I can connect from LAN many times , but a few minuts later it stop working, Wemos D1 respond to ping, but Web Server is down.

I try with some boars: "WeMos D1", "NodeMCU 0.9 (ESP-12 Module)" and "Generic ESP-8266 Module" with same results.

This is a program code:

//This example will set up a static IP - in this case 192.168.1.99

#include <ESP8266WiFi.h>  
#include <ESP8266WebServer.h> //desperate try, I include this library


const char* ssid = "my-ssid";
const char* password = "my-ssid-pass";

int ledPin = D7;

WiFiServer server(80);
IPAddress ip(192, 168, 1, 99); // where xx is the desired IP Address
IPAddress gateway(192, 168, 1, 1); // set gateway to match your network

void setup() {
 Serial.begin(115200);
 delay(10);


 pinMode(ledPin, OUTPUT);
 digitalWrite(ledPin, LOW);

 Serial.print(F("Setting static ip to : "));
 Serial.println(ip);

 // Connect to WiFi network
 Serial.println();
 Serial.println();
 Serial.print("Connecting to ");
 Serial.println(ssid);
 IPAddress subnet(255, 255, 255, 0); // set subnet mask to match your network
 WiFi.config(ip, gateway, subnet);
 WiFi.begin(ssid, password);

 while (WiFi.status() != WL_CONNECTED) {
   delay(500);
   Serial.print(".");
 }
 Serial.println("");
 Serial.println("WiFi connected");

 // Start the server
 server.begin();
 Serial.println("Server started");

 // Print the IP address
 Serial.print("Use this URL : ");
 Serial.print("http://");
 Serial.print(WiFi.localIP());
 Serial.println("/");

}

void loop() {
 // Check if a client has connected
  WiFiClient client = server.available();
 if (!client) {
   server.begin();
   return;
 }


 // Wait until the client sends some data
 Serial.println("new client");
 while(!client.available()){
   delay(500);
 }

 // Read the first line of the request
 String request = client.readStringUntil('\r');
 Serial.println(request);
 client.flush();

 // Match the request

 int value = LOW;
 if (request.indexOf("/LED=ON") != -1) {
   digitalWrite(ledPin, HIGH);
   value = HIGH;
 }
 if (request.indexOf("/LED=OFF") != -1){
   digitalWrite(ledPin, LOW);
   value = LOW;
 }



 // Return the response
 client.println("HTTP/1.1 200 OK");
 client.println("Content-Type: text/html");
 client.println(""); //  do not forget this one
 client.println("<!DOCTYPE HTML>");
 client.println("<html>");

 client.println("<h1 align=""center""><img src=""http://WEBIMAGESTORED/arduino/logo.jpg"" width=""100"" height=""100""></h1>");
 client.println("<h1 align=""center"">Motor Persiana </h1>");
 client.println("<p align=""center"">
");
 client.println("<a href=""/LED=ON""><img src=""http://WEBIMAGESTORED/arduino/on.jpg"" width=""80"" height=""80"" border=""0""></a></p>");
 client.println("<p align=""center""><a href=""/LED=OFF""><img src=""http://WEBIMAGESTORED/arduino/off.jpg"" width=""80"" height=""80"" border=""0""></a>
");
 client.println("</p>");  
 client.println("</html>");    

 delay(500);
 Serial.println("Client disconnected");
 Serial.println("");
 
}

Any help is welcome. Ty in advance

First suggestion - use the Code Tag button, </>, in the menu above.
I got it this time, you get it done next time.

Thanks, Moderator