ethernet shield get nothing like posted url

I have the code below making a get HTTP get request but nothing happens if I paste the url into a browser it works fine. I have used wireshark to check the data packets and my get request through the shield looks nothing like the get request I am making?? I am completely stuck as to why this is, if anyone can help I would be very grateful. I have included the screen dumps from wireshark

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 0, 50 }; // ip in lan assigned to arduino
//byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
//byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
byte myserver[] = { 192, 168, 0, 34 }; // zoomkat web page server IP address
EthernetClient client;
//////////////////////

void setup(){

Ethernet.begin(mac, ip);
//Ethernet.begin(mac, ip, gateway, gateway, subnet);
Serial.begin(9600);
Serial.println("Better client test 4/04/12"); // so I can keep track of what is loaded
Serial.println("Send an e in serial monitor to test"); // what to do to test
}

void loop(){
// check for serial input
if (Serial.available() > 0) //if something in serial buffer
{
byte inChar; // sets inChar as a byte
inChar = Serial.read(); //gets byte from buffer
if(inChar == 'e') // checks to see byte is an e
{
sendPOST(); // call sendGET function below when byte is an e
}
}
}

//////////////////////////

void sendPOST() //client function to send/receive GET request data.
{

if (client.connect("192.168.0.34", 81)) { //starts client connection, checks for connection
Serial.println("connected");
//client.println("GET 192.168.0.34:81/tenHsServer/tenHsServer.aspx?t=ab&f=ToggleDevice&d=E3 HTTP/1.1");
client.println("GET 192.168.0.34:81/tenHsServer/tenHsServer.aspx?t=ab&f=ToggleDevice&d=E3 HTTP/1.1");

Serial.println();
client.println(); //end of get request
}
else {
Serial.println("connection failed"); //error message if no client connect
Serial.println();
}
Serial.println();
Serial.println("disconnecting.");
Serial.println("==================");
Serial.println();
client.stop(); //stop client

}

If you used 192.168.0.34 in your browser and it worked without a port added, then this is wrong: Change the 81 to 80. Also change the ip of the server to the myserver variable.

// change this
if (client.connect("192.168.0.34", 81)) {  //starts client connection, checks for connection
// to this
if (client.connect(myserver, 80)) {  //starts client connection, checks for connection

Also uncomment and assign correct IP's for Subnet Mask and Gateway or else your Ethernet Shield won't even reach past your local network.

In fact, your posted example shouldn't even compile as you are using two varables to start the device that you haven't declared and initialised (they are commented out).

Also looks like your GET request is wrong. You don't need the server part in there. You add a 'HOST :' bit at the end with your destination hostname.

I'm not at my PC to look at my own code at the moment but you need to go back and look atbthe ethernet example. The only issue with the examplemis it doesn't send the HOST header so doesn't work with shared hosting with multiple sites on a shared IP. You have to add the host header so the server know which site you are after.

Hopefully it gives you some pointers until I might get the chance to look again later.

Below is the proper format when using HTTP/1.1.

  if (client.connect(serverName, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.1"); //download text
    client.println("Host: web.comporium.net");
    client.println("Connection: close");  //close 1.1 persistent connection  
    client.println(); //end of get request
  }

I am now including my gateway and subnet and using all parameters in ethernet.begin.

The server I am wanting to speak to is on my local network. I have two webservers apache on port 80 and the homeautomation has its own webserver software built in on port 81. The port 81 server is what I am wanting to communicate with.

I only get a response every 10 or so attempts and have included a screen dump.

 if (client.connect(myserver, 81)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET /tenHsServer/tenHsServer.aspx?t=ab&f=ToggleDevice&d=E3 HTTP/1.1"); //download text
    client.println("Host: 192.168.0.34");
    client.println("Connection: close");  //close 1.1 persistent connection  
    client.println(); //end of get request

https://dl.dropboxusercontent.com/u/102059869/screenDump.odt

I can't see what else is wrong.

How quickly are you doing each request after the previous one?
Are you receiving the server response or doing a client.flush ()?
Are you doing a client.close () after each connection?

It almost sounds like you could be doing quick requests (maybe every loop ()) and then seeing a delay due to the server sending it's response, before the next successful connect.

Post your FULL revised code.

In the ip addresses you may try changing the 0 to a 1 like below.

byte ip[] = { 192, 168, 1, 50 }; // ip in lan assigned to arduino
//byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
//byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
byte myserver[] = { 192, 168, 1, 34 }; //

Hi

byte ip[] = { 192, 168, 1, 50 }; // ip in lan assigned to arduino
//byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
//byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
byte myserver[] = { 192, 168, 1, 34 }; //

Changing the 0's to 1's for the various IP addresses will just mean nothing works, all my devices are in the 192.168.0 range and I am only interested in communication between a webserver and client on my local area network.

the issue is why when I check my data packets with wire shark the GET the arduino creates looks nothing like the URL I can paste in a browser and everything works?

Do I need to check a firm where version of my ethernet shield, how would I do such a thing??

is there a way to replicate copying and pasting the URL into the browser, I appreciate this may not be the done thing, but at least it would work.

I shall check the Jquery Get command that work on my custom website this evening using Wireshark and see how it compares.

many thanks

Here is the wire shark result from my website using jquery to make the the same GET request as you can see its the same as pasting the url into the browser, I don't understand why adruino get is different in the data packets.

here is my code as it stands currently, I press the keyboard every couple of seconds when making the request.

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 0, 50 }; // ip in lan assigned to arduino
byte gateway[] = { 192, 168, 0, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
byte myserver[] = { 192, 168, 0, 34 }; // zoomkat web page server IP address
EthernetClient client;
//////////////////////

void setup(){

  //Ethernet.begin(mac, ip);
  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  Serial.begin(9600);
  Serial.println("Better client test 4/04/12"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendPOST(); // call sendGET function below when byte is an e
    }
  } 
}

//////////////////////////

void sendPOST() //client function to send/receive GET request data.
{
  if (client.connect(myserver, 81)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET /tenHsServer/tenHsServer.aspx?t=ab&f=ToggleDevice&d=E3 HTTP/1.1"); //download text
    client.println("Host: 192.168.0.34");
    client.println("Connection: close");  //close 1.1 persistent connection  
    client.println(); //end of get request  
  }
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }
  Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop(); //stop client
}

jasemilly:
the issue is why when I check my data packets with wire shark the GET the arduino creates looks nothing like the URL I can paste in a browser and everything works?

When you enter a URL in your browser address field the browser will send an HTTP GET request to the web server. This request will include parts of the URL plus lot of other information about the browser and its capabilities.

Your Arduino will need to send an HTTP GET request which is similar to the one the browser sent, but it doesn't need to include all the information the browser sent. The screen shots you provided don't show us what the Arduino actually sent so we can't know whether it's correct, but it ought to correspond directly to your Arduino code - if it doesn't then most likely you're looking at the wrong conversation.

You can try the below code to see it will work with your network setup.

//zoomkat 9-22-12
//simple client test
//for use with IDE 1.0.1
//with DNS, DHCP, and Host
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields
//remove SD card if inserted

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address

char serverName[] = "web.comporium.net"; // zoomkat's test web page server
EthernetClient client;

//////////////////////

void setup(){

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }

  Serial.begin(9600); 
  Serial.println("Better client test 9/22/12"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendGET(); // call sendGET function below when byte is an e
    }
  }  
} 

//////////////////////////

void sendGET() //client function to send/receive GET request data.
{
  if (client.connect(serverName, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.1"); //download text
    client.println("Host: web.comporium.net");
    client.println("Connection: close");  //close 1.1 persistent connection  
    client.println(); //end of get request
  } 
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
    Serial.print(c); //prints byte to serial monitor 
  }

  Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop(); //stop client

}

I have changed tack, I have a php script on a custom webpage that speaks to the server I am having trouble speaking to through the Arduino, I have created a Sketch that speaks to this PHP file. In wireshark I can see the Get results, also Zoomkats example code speaks to his website(a big thank you I was starting to think the kit maybe faulty!!).

Hopefully I can get things moving a little!!! Is there anyway to step through Sketches or other debugging tools?

thanks

After a xmas break and a fresh look at it I changed from tring the Get method to a POST, and it all worked I am pretty certain the issue was on the server side.

Thanks for everyone's help