random internet connection fails

hi all

i got some internet problems, pretty random, sometime the arduino go well over a week, then i need to reboot it twice a week

using ajax to control lighting

first was arduino uno, was running but memory was taken @ 90+%
so i decide to change to mega, same problem

someone have the same problem? any advice, or if i add a ping to 192.168.1.1 could help

thanks a lot

eth_websrv_SD_Ajax_in_out.ino (9.26 KB)

rename the index.txt to index.htm to try it over the net

index.txt (5.86 KB)

You need to put some debugging in that code. Add these three lines and post what the last serial message is.

   if (client) {  // got client?

// add this        
        Serial.print("New client...");
       
        boolean currentLineIsBlank = true;
        while (client.connected()) {
            if (client.available()) {   // client data available to read
                char c = client.read(); // read 1 byte (character) from client
                // limit the size of the stored received HTTP request
                // buffer first part of HTTP request in HTTP_req array (string)
                // leave last element in array as 0 to null terminate string (REQ_BUF_SZ - 1)
                if (req_index < (REQ_BUF_SZ - 1)) {
                    HTTP_req[req_index] = c;          // save HTTP request character
                    req_index++;
                }
                // last line of client request is blank and ends with \n
                // respond to client only after last line received
                if (c == '\n' && currentLineIsBlank) {

// and this
                    Serial.print("sending response...");
                    
                    // send a standard http response header

// then farther down,
        delay(1);      // give the web browser time to receive the data
        client.stop(); // close the connection
// add this
        Serial.println("disconnected");

Initializing SD card...
SUCCESS - SD card initialized.
SUCCESS - Found index.htm file.
New client...sending response...GET / HTTP/1.1
Host: 192.168.1.134
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windisconnected
New client...sending response...GET /ajax_inputs&nocache=746131.517706375 HTTP/1.1
Host: 192.168.1.134
Connection: keep-alive
User-Agent: Mozilla/5.disconnected
New client...sending response...GET /favicon.ico HTTP/1.1
Host: 192.168.1.134
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64disconnected
New client...sending response...GET /ajax_inputs&nocache=900318.5547456907 HTTP/1.1
Host: 192.168.1.134
Connection: keep-alive

arduino was crashed tonight.. when i plug the computer to read serial, the arduino seem to reset itself
and all are ok

i got 9v power supply and the usb cable to debug when i need it