Ethernet web server dies after some time (random timeframe)

Hey gang.

I’m am ethernet shield on an UNO. I have a direct connection to my computer with a crossover cable. I’ve tried this on both a PC and Mac laptop with the same results…

Point of this sketch…

By accessing the web server (with either a browser or AIR app) and passing vars in the URL I’m setting the RBG values. Like so… http://192.168.0.2/?$000255000| I’m changing a strip NeoPixels. FUN!

Works like a champ for a random amount of time (anywhere from 30 secs to 30 mins) and then the sever is no longer accessible.

Here’s my sketch…

#include <SPI.h>
#include <Ethernet.h>
#include <SPI.h>
#include <Ethernet.h>
#include <Adafruit_NeoPixel.h>
#define PIN 6

const int NUMOFPIXELS = 5;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMOFPIXELS, PIN, NEO_GRB + NEO_KHZ800);

boolean incoming = 0;
int charCounter = 0;
char tempChar[20];

int rTarget = 0;
int gTarget = 0;
int bTarget = 0;

int rCurrent = 0;
int gCurrent = 0;
int bCurrent = 0;

char buff[4];// Need room for null

boolean isColorChange = false;

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 
  0x90, 0xA2, 0xDA, 0x0E, 0x98, 0x81 };
IPAddress ip(192, 168, 0, 2);

// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup() {
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
  
  pinMode(6, OUTPUT);
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);
  strip.begin();
  strip.show(); // Initialize all pixels to 'off' 
}


void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        //Serial.write(c);
        
        if(c == '

I’ve seen search results on how the either net shield can sometimes trip up, but I’ve not seen a fix that I can implement.

Thanks!){
         incoming = 1;
         Serial.println(“incoming!!!”);
         //reset values for recording colors
         charCounter = 0;
       }
       
       if(incoming == 1 && c !=’


I've seen search results on how the either net shield can sometimes trip up, but I've not seen a fix that I can implement. 

Thanks! && c !='|'){
          //Serial.println(c);
          
           tempChar[charCounter] = c;
           charCounter++;
          }
        
        if(incoming && c == '|'){ 
          incoming = 0;

          Serial.println("time to parse out");
          Serial.println(tempChar);
          
          strncpy(buff, &tempChar[0], 3);
          rTarget = atoi(buff);
          //Serial.print("red:");
          //Serial.println(rTarget);
          
          strncpy(buff, &tempChar[3], 3);
          gTarget = atoi(buff);
         // Serial.print("green:");
         // Serial.println(gTarget);
          
          strncpy(buff, &tempChar[6], 3);
          bTarget = atoi(buff);
         // Serial.print("blue:");
         // Serial.println(bTarget);
        }
        
        
        
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
  //client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          client.println("success");
          client.println("</html>");
          
          
          
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } 
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.flush();
    client.stop();
    Serial.println("client disconnected");
    Serial.println();
    Serial.println();
    Serial.println();
 
  }
  
  isColorChange = false;

  if(rTarget < rCurrent)
  {
    rCurrent--;
    isColorChange = true;
  }

  if(rTarget > rCurrent)
  {
    rCurrent++;
    isColorChange = true;
  }

  if(gTarget < gCurrent)
  {
    gCurrent--;
    isColorChange = true;
  }

  if(gTarget > gCurrent)
  {
    gCurrent++;
    isColorChange = true;
  }

  if (bTarget < bCurrent)
  {
    bCurrent--;
    isColorChange = true;
  }

  if(bTarget > bCurrent)
  {
    bCurrent++;
    isColorChange = true;
  }
  
  if(isColorChange)
  {
    for (int i=0; i < NUMOFPIXELS; i++)
    {
      strip.setPixelColor(i, gCurrent, rCurrent, bCurrent);
    }
    strip.show();
  }
  
  delay(5);//delay allows change of color to happen slowly
}

I’ve seen search results on how the either net shield can sometimes trip up, but I’ve not seen a fix that I can implement.

Thanks!