user5142: I really need all the help I can get...
It's been a week now and I'm still not able to solve the problem.
I have text file on a server. The whole address is www.example.com/test.txt
I want to read the file using a GET request every 3-5 secs and parse it for further actions. But the arduino codes that I've tried till now use software serial and it keeps misbehaving. Sometimes it skips a few serial-print commands and loops back sometimes it reads the file 3-4 times and then hangs. Basically I'm getting the response only a few times but then it stops working properly. 
I want to solve this...I need a working arduino code to work with ESP8266 so that I can successfully poll a text file from server without any problems.
Here is my current code - 
 #include<SoftwareSerial.h>

    #define led 13
    SoftwareSerial esp(11, 12);
    String domain = "www.example.com";
    String request = "GET /test.txt HTTP/1.0\r\n\r\n";


    void SerialDo(String command, float time, bool debug) {
      delay(100);
      esp.print(command);

      int i = millis();
      while (millis() - i < (time * 1000)) {
        while ( (esp.available())) {
          if (debug) {
            Serial.print((char)esp.read());
          }
        }
      }

      Serial.flush();
    }

    void setup() {
      // put your setup code here, to run once:
      digitalWrite(led, OUTPUT);
      Serial.begin(9600);
      esp.begin(9600);
      esp.setTimeout(3000);
      digitalWrite(led, LOW);
      Serial.println("Hello");
      //delay(2000);
      SerialDo("AT+RST\r\n", 5, true);
      Serial.flush();
      SerialDo("AT+CWMODE=1\r\n", 0.5, true);

      delay(1000);
      //SerialDo("AT+CWLAP\r\n", 5, true);
      SerialDo("AT+CWJAP=\"Sherlock\",\"Watson@11\"\r\n", 10, true);
      SerialDo("AT+CIPMUX=0\r\n", 0.5, true);

    }

    void loop() {


      delay(1000);
      Serial.print("loop\r\n");

      SerialDo("AT+CIPMUX=0\r\n", 0.5, true);
      SerialDo("AT+CIPSTART=\"TCP\",\"" + domain + "\",80\r\n", 1.5, true);
      esp.flush();

      esp.print("AT+CIPSEND=" + String(request.length()) + "\r\n");
      delay(100);
      esp.print(request);

      String t = "";
      int i = millis();
      while (millis() - i < 1500) {
        while ((esp.available() > 0)) {
          if (true) {
            char c = (char)esp.read();
            t += c;
            Serial.print(c);
          }
        }
      }

      esp.print("AT+CIPCLOSE\r\n");

      if (t.indexOf("hello world") > -1) {
        digitalWrite(led, !digitalRead(led));
      }
  }


user10046: It seems that you're trying to do the same thing:

https://www.youtube.com/watch?v=q02f4sPghSo

Maybe it will help, I'm tryin' to do that (a POST), only that I don't have the server on a text file.

5142: <p>I really need all the help I can get...
It's been a week now and I'm still not able to solve the problem.</p>

<p>I have text file on a server. The whole address is www.example.com/test.txt
I want to read the file using a GET request every 3-5 secs and parse it for further actions. But the arduino codes that I've tried till now use software serial and it keeps misbehaving. Sometimes it skips a few serial-print commands and loops back sometimes it reads the file 3-4 times and then hangs. Basically I'm getting the response only a few times but then it stops working properly. </p>

<p>I want to solve this...I need a working arduino code to work with ESP8266 so that I can successfully poll a text file from server without any problems.</p>

<p>Here is my current code - </p>

<pre><code> #include&lt;SoftwareSerial.h&gt;

    #define led 13
    SoftwareSerial esp(11, 12);
    String domain = "www.example.com";
    String request = "GET /test.txt HTTP/1.0\r\n\r\n";


    void SerialDo(String command, float time, bool debug) {
      delay(100);
      esp.print(command);

      int i = millis();
      while (millis() - i &lt; (time * 1000)) {
        while ( (esp.available())) {
          if (debug) {
            Serial.print((char)esp.read());
          }
        }
      }

      Serial.flush();
    }

    void setup() {
      // put your setup code here, to run once:
      digitalWrite(led, OUTPUT);
      Serial.begin(9600);
      esp.begin(9600);
      esp.setTimeout(3000);
      digitalWrite(led, LOW);
      Serial.println("Hello");
      //delay(2000);
      SerialDo("AT+RST\r\n", 5, true);
      Serial.flush();
      SerialDo("AT+CWMODE=1\r\n", 0.5, true);

      delay(1000);
      //SerialDo("AT+CWLAP\r\n", 5, true);
      SerialDo("AT+CWJAP=\"Sherlock\",\"Watson@11\"\r\n", 10, true);
      SerialDo("AT+CIPMUX=0\r\n", 0.5, true);

    }

    void loop() {


      delay(1000);
      Serial.print("loop\r\n");

      SerialDo("AT+CIPMUX=0\r\n", 0.5, true);
      SerialDo("AT+CIPSTART=\"TCP\",\"" + domain + "\",80\r\n", 1.5, true);
      esp.flush();

      esp.print("AT+CIPSEND=" + String(request.length()) + "\r\n");
      delay(100);
      esp.print(request);

      String t = "";
      int i = millis();
      while (millis() - i &lt; 1500) {
        while ((esp.available() &gt; 0)) {
          if (true) {
            char c = (char)esp.read();
            t += c;
            Serial.print(c);
          }
        }
      }

      esp.print("AT+CIPCLOSE\r\n");

      if (t.indexOf("hello world") &gt; -1) {
        digitalWrite(led, !digitalRead(led));
      }
  }
</code></pre>
 10046: <p>It seems that you're trying to do the same thing:</p>

<blockquote>
  <p><a href="https://www.youtube.com/watch?v=q02f4sPghSo" rel="nofollow">https://www.youtube.com/watch?v=q02f4sPghSo</a></p>
</blockquote>

<p>Maybe it will help, I'm tryin' to do that (a POST), only that I don't have the server on a text file.</p>
