Web server stops responding

Hi

I know there is a tons of this type of threeds, but i cant find solution to my problem...

I hawe made automatic garden watering controller with atmega2560 and ethernet shield.
Im running web server from SD card with 2 pages.

All is working fine but at some default time (1h or 1week...) web server stops responding (every time when im on page and im changing something). But program dont hangs - it works normaly (buttons, rellays...).

Because im a hobby programmer (at most copy paste :slight_smile: ) i need your help.

Files are attached.

HTML files: https://ufile.io/k9w4h

Thank you

Forecast.cpp (2.72 KB)

Forecast.h (330 Bytes)

v2.5.4.ino (53.7 KB)

You're probably running out of memory (RAM). You can easily save lots of memory by using the F macro. Another way to save a lot of memory is to get rid of the String class as it fragments the memory very fast.

Also, move your Udp.begin() call from getTimeAndDate to the setup function. I haven't tested this, but repeatedly calling it may cause a socket fail.

pylon:
You're probably running out of memory (RAM). You can easily save lots of memory by using the F macro. Another way to save a lot of memory is to get rid of the String class as it fragments the memory very fast.

Thanks for helping me. If the program is running out of ram then the complete program stops and not just web server. Or im false? :slight_smile:

SurferTim:
Also, move your Udp.begin() call from getTimeAndDate to the setup function. I haven't tested this, but repeatedly calling it may cause a socket fail.

Thanks. Changed, but not tested jet

Thanks for helping me. If the program is running out of ram then the complete program stops and not just web server. Or im false?

It may react in any way, it's simply not defined as the new data that doesn't fit into memory may be written over any other information. Sometimes this ends in a freeze, sometimes just in a misbehavior.

pylon:
It may react in any way, it's simply not defined as the new data that doesn't fit into memory may be written over any other information. Sometimes this ends in a freeze, sometimes just in a misbehavior.

Do you have idea how to solve this? Can it be because to much web requests?

Thank you

I use this code to check the socket status. You can call it any time you feel necessary.

#include <utility/w5100.h>

byte socketStat[MAX_SOCK_NUM];

void ShowSockStatus()
{
  for (int i = 0; i < MAX_SOCK_NUM; i++) {
    Serial.print(F("Socket#"));
    Serial.print(i);
    uint8_t s = W5100.readSnSR(i);
    socketStat[i] = s;
    Serial.print(F(":0x"));
    Serial.print(s,16);
    Serial.print(F(" "));
    Serial.print(W5100.readSnPORT(i));
    Serial.print(F(" D:"));
    uint8_t dip[4];
    W5100.readSnDIPR(i, dip);
    for (int j=0; j<4; j++) {
      Serial.print(dip[j],10);
      if (j<3) Serial.print(".");
    }
    Serial.print(F("("));
    Serial.print(W5100.readSnDPORT(i));
    Serial.println(F(")"));
  }
}

Here is a status code list.
0x0 = available
0x14 = waiting for a connection
0x17 = connected
0x1C = connected waiting for close
0x22 = UDP

Edit: If you are using server code, one socket should show 0x14. If not, you have a problem.

SurferTim:
I use this code to check the socket status. You can call it any time you feel necessary.

#include <utility/w5100.h>

byte socketStat[MAX_SOCK_NUM];

void ShowSockStatus()
{
  for (int i = 0; i < MAX_SOCK_NUM; i++) {
    Serial.print(F("Socket#"));
    Serial.print(i);
    uint8_t s = W5100.readSnSR(i);
    socketStat[i] = s;
    Serial.print(F(":0x"));
    Serial.print(s,16);
    Serial.print(F(" "));
    Serial.print(W5100.readSnPORT(i));
    Serial.print(F(" D:"));
    uint8_t dip[4];
    W5100.readSnDIPR(i, dip);
    for (int j=0; j<4; j++) {
      Serial.print(dip[j],10);
      if (j<3) Serial.print(".");
    }
    Serial.print(F("("));
    Serial.print(W5100.readSnDPORT(i));
    Serial.println(F(")"));
  }
}




Here is a status code list.
0x0 = available
0x14 = waiting for a connection
0x17 = connected
0x1C = connected waiting for close
0x22 = UDP

Edit: If you are using server code, one socket should show 0x14. If not, you have a problem.

Thank you. I will test it tomorrow.

So what happened ?

Did you fix it?

I am having the same issue.

It had all been working fine for 18 months and then the same thing happened, port 80 closed, program still running physical button work fine.

Any more clues?