Ethernet shield + Simple example = connection failed

Hi!
I'm new to arduino and ethernet. Have some experience with AVR, but now Im stuck

I run this code on UNO with ethernetshield from sparkfun Arduino Ethernet Shield - DEV-09026 - SparkFun Electronics
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0x90, 0xa2, 0xda, 0x00, 0x78, 0x08 };
byte ip[] = { 192,168,0,150 };
byte server[] = { 64, 233, 187, 99};

#if ARDUINO > 18
#include <SPI.h> // needed for Arduino versions later than 0018
#endif
#include <Ethernet.h>
// see text for more on IP addressing
Client client(server, 80);
void setup()
{
Ethernet.begin(mac, ip); // start ethernet using the mac and IP address
Serial.begin(9600); // start the serial library:
delay(1000); // give the ethernet hardware a second to initialize
Serial.println("connecting...");
if (client.connect()) {
Serial.println("connected");
client.println("GET /search?q=arduino HTTP/1.1"); // the HTTP request
client.println();
} else {
Serial.println("connection failed");
}
}
void loop()
{
if (client.available()) {
char c = client.read();
Serial.print(c); // echo all data received to the Serial Monitor
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;:wink:
;
}
}

It gives me output via serial:
connecting... // 30 sec delay....
connection failed

disconnecting.

I'm behind a router with this config:
router ip 192.168.0.1
subnet Mask 255.255.255.0

DHCP reservation list:
Name: Arduino
MAC: 90:a2:da:00:78:08
ip: 192.168.0.150

DMZ on 192.168.0.150
no virtual server
no port forwarding

Please help me!
I'm frustrated, and need help.

That ip does not respond. I get a timeout with my web browser. Change your server ip to this:

byte server[] = { 209,191,122,70};

Thanks!

I'm trying to understand the get command and the server IP adr.

You cant just write "http://209.191.122.70/search?q=arduino" in the browser, and to the same thing..?

What do I do when i need the arduino to go to this address "utvikling.tollofsrud.no/test/test.php?string=601;650;680;9;705;650;680;9;1;0"

It is a two part deal. First, you will need to get the ip address for
utvikling.tollofsrud.no

That is your server ip. Then use this:

client.println("GET /test/test.php?string=601;650;680;9;705;650;680;9;1;0 HTTP/1.1"); // the HTTP request

Add: If you are using HTTP/1.1, you will probably need to specify a HOST in the header. If it is not your server, your web host may be using virtual domain hosting.

  if (client.connect()) {
    Serial.println("connected");
    client.println("Host: utvikling.tollofsrud.no");
    client.println("GET /test/test.php?string=601;650;680;9;705;650;680;9;1;0 HTTP/1.1"); // the HTTP request
    client.println();

played with the code:
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0x90, 0xa2, 0xda, 0x00, 0x78, 0x08 };
byte ip[] = { 192,168,0,150 };
byte server[] = { 193,202,110,148};

#if ARDUINO > 18
#include <SPI.h> // needed for Arduino versions later than 0018
#endif
#include <Ethernet.h>
// see text for more on IP addressing
Client client(server, 80);
void setup()
{
Ethernet.begin(mac, ip); // start ethernet using the mac and IP address
Serial.begin(9600); // start the serial library:
delay(1000); // give the ethernet hardware a second to initialize
Serial.println("connecting...");
if (client.connect()) {
Serial.println("connected");
client.println("Host: http://tollofsrud.no");
client.println("GET /PHPFile2.php?watt=1814 HTTP/1.1"); // the HTTP request
client.println();
} else {
Serial.println("connection failed");
}
}
void loop()
{
if (client.available()) {
char c = client.read();
Serial.print(c); // echo all data received to the Serial Monitor
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;:wink:
;
}
}

I get this over the serial:

connecting...
connected

501 Method Not Implemented

Method Not Implemented

Host: to /b-one-default.html not supported.

disconnecting.

any suggestions on how I get this to work?

Simple client test code you can try. Also use the # in the post tool bar to put your code in a code box.

//zoomkat 11-13-10
//simple ethernet client test code
//for use with IDE 0021 and W5100 ethernet shield
//modify the arduino lan ip address as needed
//open serial monitor to see what the arduino receives
//push the shield reset button to run client again

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 102 }; // Arduino IP address
byte server[] = { 208, 104, 2, 86 }; // zoomkat's web site

Client client(server, 80);

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
  Serial.println("starting simple arduino client test");
  Serial.println();

  delay(1000);

  Serial.println("connecting...");

  if (client.connect()) {
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    Serial.println("==================================");
    Serial.println("");
    client.stop();
    for(;;);
  }
}

What I suggested:
client.println("Host: **utvikling.**tollofsrud.no");

What you used:
client.println("Host: **http://**tollofsrud.no");

Do not use the protocol!! No "http://".

EDIT: In my haste, I put the header info in backwards. :blush:
The Host should follow the GET.

client.println("GET /PHPFile2.php?watt=1814 HTTP/1.1"); // the HTTP request
client.println("Host: utvikling.tollofsrud.no"); // the URL of the requested site
client.println();

The Host parameter is supposedly required by HTTP/1.1. Many web hosts use virtual domain hosting, where several domains are accessed through one public IP. The Host field is used by the web server to determine which of virtual domains you want.

changed to "HTTP/1.0" and it works....