Mega + Wifi shield get request timeout

Hi,
I'm trying to read a webpage to eventually parse it and extract data. Connection and get work ok but when printing the page to serial it appears to timeout. The timeout may be over serial, but I think not as it should only be printing a byte at a time. The page is ~47kB and only ~6 - 6.1kB is read and makes it to the terminal. The actual amount printed varies, so I think it may be a timer rather than a buffer.
The following establishes the connection.

if (client.connect(server, 80)) {
    Serial.println("connected to server");
    // Make a HTTP request:
    client.println("GET http://www.energyelephant.com/page-traffic-light/");
    client.println("Host: www.google.com");
    client.println("Connection: close");
    client.println();
  }

And this reads and prints.

while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

As I'm fairly new to Wifi on Arduino I don't know what timeouts/buffer limits are common. If anyone has any suggestions, I'd appreciate them.
Thanks

A couple things. The GET should have only the page in the request, and the domain should go in the Host parameter.

if (client.connect(server, 80)) {
    Serial.println("connected to server");
    // Make a HTTP request:
    client.println("GET /page-traffic-light/ HTTP/1.0");
    client.println("Host: energyelephant.com");
    client.println("Connection: close");
    client.println();
  }

You should read until the server closes the connection like this. This is the “Perfect World” version. The “Real World” version has a timeout feature to prevent a lockup if the connection breaks or the server stalls.

while(client.connected() {
  while (client.available()) {
     char c = client.read();
     Serial.write(c);
   }
}

edit: Oops! I forgot the protocol in the GET line. HTTP/1.0

Thanks,
I was too busy assuming it was an Arduino issue to check I'd edited everything correctly :roll_eyes:.
I'll try this tomorrow and update, this looks like the fix thought.

The host was part of the problem, I was also using IDE 1.0.5, this has issues with Wifi. IDE 1.0.3 works though.

Then you probably haven’t done the wifi firmware upgrade.