Webserver not reachable after some time

Hello all,

I am using 2 webservers at my home to control relays.
One of them is on Uno with etherenet shield, other is a wemos esp8266 wi-fi board.
I have the following issue with both: after some time the webservers are not reachable.
The IP connectivity is ok, they both answer to Ping, but webpage is not reachable.
Then it gets back working either if I reboot the boards or reboot the router.
It is very annoying when I want e.g to open my garage door in morning webpage is unreachable..
Does anyone have solution for similar issues?

Br,

Then it gets back working either if I reboot the boards or reboot the router.

Sounds like a router configured with a very low lease time. Try increasing the DHCP lease time on the router.

actually I am using static IP address for both boards (not by dhcp). And even when the web pages cannot be reached, both boards are answering to PING, so network connection is ok...

And you are sure that if the system is in the state that you cannot access the web page, a restart of the router (without touching the Arduinos) will make the web page accessible again?

Without showing the sketch, nobody - beside you - can check it.
Therefore - if you want to get assistance - post your well documented code.

pylon:
And you are sure that if the system is in the state that you cannot access the web page, a restart of the router (without touching the Arduinos) will make the web page accessible again?

Yes, this is the case!

Yes, here is 1 of my codes (this one is running on the wemos, actually it is used to switch 4 relays):

#include <ESP8266WiFi.h>
 
const char* ssid = "......";
const char* password = ".......";

int kapu1 = D2;
int villany1 = D5;
int kapu2 = D6;
int villany2 = D7;
String inString = String(50);

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

void setup() {
  Serial.begin(115200);
  delay(10);
 
 
  pinMode(kapu1, OUTPUT);
  digitalWrite(kapu1, LOW);
  pinMode(villany1, OUTPUT);
  digitalWrite(villany1, LOW);
  pinMode(kapu2, OUTPUT);
  digitalWrite(kapu2, LOW);
  pinMode(villany2, OUTPUT);
  digitalWrite(villany2, 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) {
    
  
 
  // Wait until the client sends some data
  Serial.println("new client");
 boolean current_line_is_blank = true;
  while (client.connected()) {

  if (client.available()) {

  
  char c = client.read();
   
  //Serial.write(c);
   if (inString.length() < 50) {
            inString.concat(c);
           
         }
 
 if (c == '\n' && current_line_is_blank) {

      Serial.println(inString);
 

  // Match the request
 

  if (inString.indexOf("b5") != -1) {
    digitalWrite(kapu1, HIGH);
   
    delay(1000);
    digitalWrite(kapu1, LOW);
    
    
    //itt kell a garazs 1 kaput felnyitni
    
  } 
  if (inString.indexOf("b6") != -1){

    digitalWrite(villany1, !digitalRead(villany1));

    Serial.println(digitalRead(villany1));
    
   
 //itt kell a garazs 1 villanyt felkapcsolni
    
  }

if (inString.indexOf("b7") != -1) {
     digitalWrite(kapu2, HIGH);
   
    delay(1000);
    digitalWrite(kapu2, LOW);
    //itt kell a garazs 2 kaput felnyitni
    
  } 

 if (inString.indexOf("b8") != -1) {

     digitalWrite(villany2, !digitalRead(villany2));


  Serial.println(digitalRead(villany2));
    //itt kell a garazs 2 villanyt felkapcsolni
    
  } 


//return HTTP response

          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          client.println("<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\" \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">");
         
          client.println("<html><body><h2>Garazs vezerlo</h2><font size= 4><form method=GET>");
          client.println("

<input type=submit name=b5 value=Garazskapu_1>");
          client.println("

<input type=submit name=b6 value=Garazs_1_villany>");
          client.println("

<input type=submit name=b7 value=Garazskapu_2>");
          client.println("

<input type=submit name=b8 value=Garazs_2_villany>");
          client.println("

<a href=\"http://192.168.1.250:19136/?pw=mypw\">Vissza a hazhoz</a>");

    break;
         
  }
  
  if (c == '\n') {
          // we're starting a new line
          current_line_is_blank = true;
        } else if (c != '\r') {
          // we've gotten a character on the current line
          current_line_is_blank = false;
        }

  }
  
  }

 
  delay(1);
   client.stop();
  Serial.println("Client disconnected");
  Serial.println("");
   inString = "";
 
}
 }

Yes, this is the case!

That means your router is the problem and not the Arduino or the ESP. It might be a firewall thing or some NAT stuff but I'm quite sure you won't have this problem if you connect the PC and the boards by a simple switch/access point.