Adafruit cc3000 - issue with blink LED

Arduino UNO
Adafruit cc3000 Wifi shield Firmware-1.24

I did not see similar question.
I want to make wifi controlled led, turn on/off from anywhere in the world using Internet. For this reason I made website and "state.php" page that contains numbers "0" or "1". I used a standard Adafruit cc3000 WebClient Library to connect "state.php" page. At the end of the code in "while (www.connected())" loop I added if condition for controll led.
Generally speaking the goal is reached but...
I noticed when "state.php" content is "1" LED lights with periodic blinking.
I guess it happens during the passage through the loop code, but do not know to solve it.
Also, after a while, WiFi Shield stops working and I can not control LED over the Internet.
I don't know why this is happening. Can someone help.
Below is my code.

#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>
#include "utility/debug.h"

#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
#define ADAFRUIT_CC3000_VBAT  5
#define ADAFRUIT_CC3000_CS    10
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
                                         SPI_CLOCK_DIVIDER); // you can change this clock speed

#define WLAN_SSID       "MyWLANSSID"           // cannot be longer than 32 characters!
#define WLAN_PASS       "MyWLANPASS"
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY   WLAN_SEC_WPA2

#define IDLE_TIMEOUT_MS  6000      

#define WEBSITE      "www.mywebsite.com"
#define WEBPAGE      "/state.php"

uint32_t ip;
int lednum = 7;

void setup() {
  Serial.begin(115200);
  pinMode(lednum, OUTPUT);
     /* Initialise the module */
    Serial.println(F("Initializing..."));
    if (!cc3000.begin())
    {
      Serial.println(F("Couldn't begin()! Check your wiring?"));
      while(1);
    }

          /* Delete any old connection data on the module */
          Serial.println(F("Deleting old connection profiles"));
          if (!cc3000.deleteProfiles()) {
            Serial.println(F("Failed!"));
            while(1);
          }

              Serial.print(F("Attempting to connect...")); 
              //Serial.println(WLAN_SSID);
              if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
                Serial.println(F("Failed!"));
                while(1);
              }
              Serial.println(F("\nConnected!"));
      
                   // Try looking up the website's IP address
                   ip = 0;
                   while (ip == 0) {
                    if (! cc3000.getHostByName(WEBSITE, &ip)) {
                      Serial.println(F("Couldn't resolve!"));
                    }
                    delay(500);
                    }       
}


void loop() {

        /* Try connecting to the website.
        Note: HTTP/1.1 protocol is used to keep the server from closing the connection before all data is read.
        */
        Adafruit_CC3000_Client www = cc3000.connectTCP(ip, 80);
        if (www.connected()) {
          www.fastrprint(F("GET "));
          www.fastrprint(WEBPAGE);
          www.fastrprint(F(" HTTP/1.1\r\n"));
          www.fastrprint(F("Host: ")); 
          www.fastrprint(WEBSITE); 
          www.fastrprint(F("\r\n"));
          www.println();
        } else {
          Serial.println(F("Connection failed"));    
          return;
        }

        /* Read data until either the connection is closed, or the idle timeout is reached. */ 
        String data;
        data = String("");
        unsigned long lastRead = millis();
        while (www.connected()) 
        {
            while (www.available()) 
            {
            char c = www.read();
            data += c;
            }

        data.trim();
        int lenght = data.length();
        String sign = data.substring(lenght-4, lenght-3);
        int b = atoi(sign.c_str());
        Serial.println(b);

            if(b==1){
             digitalWrite(lednum, HIGH);
            } 
            if(b==0){
             digitalWrite(lednum, LOW);
            }       
        }
}

After you get a disconnect message from the server, you must call www.stop().

        while (www.connected())
        {
            while (www.available())
            {
              char c = www.read();
              data += c;
            }

           data.trim();
           int lenght = data.length();
           String sign = data.substring(lenght-4, lenght-3);
           int b = atoi(sign.c_str());
           Serial.println(b);

            if(b==1){
               digitalWrite(lednum, HIGH);
            }
            if(b==0){
               digitalWrite(lednum, LOW);
            }       
        }

// add this call
        www.stop();

But that may not be your only problem. It appears you could be running out of SRAM also. Many servers return more than the SRAM can handle.

I added "www.stop ()" as you suggested.
But unfortunately, the LED is still blinking.
I noticed on the serial monitor during the loop a certain number of "0".
Precisely 17 "0", although it should be all "1".

I have attached a picture serial.jpg

serial.jpg

Are you aware the response from the server may come in more than one packet? The "while(www.available())" loop reads only one of the packets.

I didn't know and what is the solution of problems.

Is the solution optimization SRAM?