ESP8266 Web Get doesn't work

I have the sparkfun ESP8266 wifi shield with an external antenna. It connects and pings good (I think). It gets an IP for sure but the output that I’m getting is:

The website I’m calling is definitely working and I have it logging any calls to it and it’s never getting called.

Starting Connected to IP: 192.168.1.65
Getting
ERROR

busy p…

busy p…

ERROR
Done

The code:

#include <SoftwareSerial.h>
#include <SparkFunESP8266WiFi.h>

const char mySSID = “mywifi”;
const char myPSK = “mypassword”;

void setup()
{
Serial.begin(9600);
Serial.print("Starting ");

while (esp8266.begin() != true)
{
Serial.print(“Error connecting to ESP8266.”);
delay(1000);
}

ESP8266Client client;

if (esp8266.status() <= 0)
{
while (esp8266.connect(mySSID, myPSK) < 0)
{
delay(1000);
}

}
Serial.print("Connected to IP: ");
Serial.println(esp8266.localIP());
Serial.print("Getting ");

esp8266.print(“GET / HTTP/1.1\nHost: mysite.com\nConnection: close\n\n”);

delay(3000);

while (esp8266.available())
Serial.write(esp8266.read());

if (client.connected())
client.stop();

Serial.println("Done ");
}

void loop()
{

}

Any thoughts?

esp8266.print("GET / HTTP/1.1[color=red]\n[/color]Host: mysite.com[color=red]\n[/color]Connection: close[color=red]\n\n[/color]");

Don't use \n in your http request but use \r\n, because it's defined as the line break in the HTTP protocol specification (RFC2616) - some server will work with just '\n' but that's a bad idea to take the chance.

The way you wait for the answer ( 3 second pause and then read all that has arrived) is pretty poor. Implement a proper read of an HTTP answer or you will miss data due to buffer overflow or not waiting long enough and emptying all the incoming buffer

Thank you for the reply. I tried that (finding it on various samples) and it didn’t change the outcome (identical error response).

The data being returned from the web page is simply “ok” so that I know it’s doing something. I don’t really know how to do a “proper” http answer. All the demo’s seem to treat the code sequential. I added the delay just as an “in case” but it has the same result with that or without that.

Before you issue the get, you must make a connection to the web server on port 80 (usually). Your URL must be of the type http://. Https:// is not supported.

Edit: Since you are using the sparkfun library, look at this example: https://learn.sparkfun.com/tutorials/esp8266-wifi-shield-hookup-guide/using-the-esp8266-at-library

Your code is missing the equivalent of:

retVal = client.connect("sparkfun.com", 80); // Connect to sparkfun (HTTP port)
if (retVal > 0)
    Serial.println("Successfully connected!");

That did it - thank you so much!

Here are the changes for others who may be suffering like me haha:

if ( !client.connect(“www.mysite.com”, 80) ) {
Serial.print(“Error connecting to website.”);
}

client.print(“GET / HTTP/1.1\r\nHost: www.mysite.com\r\nConnection: close\r\n\r\n”);