Project

General

Profile

browseURL not connecting to websites correctly

Added by Eisenhorn14 almost 5 years ago

Hi all,

I am currently using Arduino IDE 1.0.5-r2, an Arduino UNO rev 3, and DK electronics ethernet shield v2.0 with hardware controller enc28j60 and ethernet adapter HansRun HR911105A.

I have been trying to get the webClient example working. I have been following the example at lucadentella.it, specifically this example http://www.lucadentella.it/en/2012/02/19/enc28j60-e-arduino-3/, which is pretty much the exact same as the webClient example except with an actual website (http://www.lucadentella.it/demo/aphorisms.php) rather than google.com/foo/bar. My code can successfully find the ip of the website via dns, however, the website always returns “404 website not found”.

I believe the error is in the browseURL, but I will link all of my code. As well as a copy of the serial print out.

// Demo using DHCP and DNS to perform a web client request.
// 2011-06-08  http://opensource.org/licenses/mit-license.php

#include 

// ethernet interface mac address, must be unique on the LAN
static uint8_t mymac[] = { 0x38, 0xEE, 0xF4, 0x34, 0x94, 0x73 };

uint8_t Ethernet::buffer[700];
static uint32_t timer;

const char website[]= "www.lucadentella.it";


// called when the client request is complete
static void my_callback (byte status, word off, word len) {
  Serial.println(">>>");
  Ethernet::buffer[off+300] = 0;
  Serial.print((const char*) Ethernet::buffer + off);
  Serial.println("...");
}

void setup () {
  Serial.begin(9600);
  Serial.println("\n[webClient]");

  if (!ether.begin(sizeof Ethernet::buffer, mymac, 10)) 
    Serial.println( "Failed to access Ethernet controller");
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip);  
  ether.printIp("DNS: ", ether.dnsip);  

  if (!ether.dnsLookup(website))
    Serial.println("DNS failed");

  ether.printIp("SRV: ", ether.hisip);
}

void loop () {
  ether.packetLoop(ether.packetReceive());

  if (millis() > timer) {
    timer = millis() + 5000;
    Serial.println();
    Serial.print("<<< REQ ");
    ether.browseUrl(PSTR("/demo/"), "aphorisms.php", website, my_callback);
   //I have tried these other versions of ether.browseUrl as well:
   // ether.browseUrl(PSTR("/demo/aphorisms.php"), "", website, my_callback);
    //ether.browseUrl(PSTR(""), "/demo/aphorisms.php", website, my_callback);
  }
}

Serial Print out:

[webClient]
IP:  128.95.205.138
GW:  128.95.205.100
DNS: 128.95.42.2
SRV: 217.64.195.207

<<< REQ 
<<< REQ >>>
HTTP/1.1 404 Not Found
Date: Wed, 04 Jun 2014 19:31:45 GMT
Server: Apache
Last-Modified: Mon, 14 Mar 2005 22:42:36 GMT
ETag: "40094544-556-3f24da0e68f00"
Accept-Ranges: bytes
Content-Length: 1366
Vary: Accept-Encoding
Connection: close
Content-Type: text/html

Any ideas? I receive errors from any websites when I try to pull their html data down.
Thanks for any help!


Replies (1)

RE: browseURL not connecting to websites correctly - Added by tochinet almost 5 years ago

Maybe you should try to get some root page from a server first ?

    (1-1/1)