Pages: [1]   Go Down
Author Topic: Updating IP using update.dnsExit.com  (Read 1489 times)
0 Members and 1 Guest are viewing this topic.
Sonoma, California
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a solution posted under a better description.  Sending HTTP: get response to a server, code for dnsExit.com IP dynamic DNS update service


I would like to make a security camera available over the internet.  My ISP uses DHCP.  I have signed up with dnsexit.com, a company that offers a nice variety of services and has tested a subset of my code to confirm their server is functioning correctly (kudos to their customer service).  In 2days of staring, crying, and 3AM  thoughts I think I have exhausted all combinations of HTML structure (trying GET POST and HTML headers)  and hope a member can spot a simple false assumption that I am making.  This is using an Arduino UNO with the Arduino Ethernet shield W5100 chip, SD chip not installed (that also seems to kill everything).  If you create a web page using the core HTML request contained below in Firefox it works perfectly.  

The code (thank you  to many postings here):
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xxx, 0xxx  };
  //char dnsexitServer[] = ("http://update.dnsexit.com");  this didn't get very far either - Tom
IPAddress server (67,214,161,141);    //(67,214,175,75);

EthernetClient client;

void setup() {
  Serial.begin(9600);
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }
 
  //Give time to initialize:
  delay(2000);
 
  if(client.connect(server, 80)){
    Serial.println("Connected to dnsexit.com");
    client.println("GET / HTTP/1.1\r\n");
    client.println("Host: update.dnsexit.com\r\n");
  
       //Also tried using their IP directly - client.println("<form action=\"67.214.161.141/RemoteUpdate.sv?\">");
    client.println("<form action=\"update.dnsexit.com/RemoteUpdate.sv?\">");  
    client.println("<input type=hidden name=\"login\" value=\"Tomxxxx\">");
    client.println("<input type=hidden name=\"password\" value=\"xxxxxxx\">");
    client.println("<input type=hidden name=\"host\" value=\"tomandxxxxx.com\">");
    client.println("<input type=hidden name=\"myip\" value=\"xx.103.178.xxx\"");
    client.println("</form>");
  
  
    //Wait for response
    delay(3000);
    Serial.println(client.available());
  }
}

void loop()
{
  // if there are incoming bytes available
  // from the server, read them and print them:
  if (client.available()) {
    //Serial.println("in client available loop");
    char c = client.read();
    Serial.print(c);
  }
  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    for(;smiley-wink
      ;
  }
}

Message returned from their server:

Connected to dnsexit.com
490
HTTP/1.1 400 Bad Request
Date: Thu, 06 Sep 2012 21:46:26 GMT
Server: Apache/2.2.3 (CentOS)
Content-Length: 309
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.2.3 (CentOS) Server at update.dnsexit.com Port 80</address>
</body></html>

disconnecting.

<hr>
<address>Apache/2.2.3 (CentOS) Server at update.dnsexit.com Port 80</address>
</body></html>

There is also a simple alternative but it also fails.  Only the core HTML is changed.  Entering the action line in a Firefox browser address bar works great.  Unfortunately I do not know how to enter it into the Arduino client "address bar".  This returns the same "Your browser sent a request that this server could not understand" error message.

 if(client.connect(server, 80)){
    Serial.println("Connected to dnsexit.com");
    client.println("GET / HTTP/1.1\r\n");
    client.println("Host: update.dnsexit.com\r\n");
  
       //Also tried using their IP directly - client.println("<form action=\"67.214.161.141/RemoteUpdate.sv?\">");
    client.println("<form action=\"http://update.dnsexit.com/RemoteUpdate.sv?login=Tomxxx_&password=XXXXX_&host=tomandXXX.com&myip=XX.103.178.XXX\">");
    
    client.println("</form>");
« Last Edit: September 16, 2012, 10:04:06 pm by TomNorth7 » Logged

Pura Vida

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9541
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just post the url that works in a browser GO box without all the other code.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Sonoma, California
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, I have noticed you have helped many people. It sounds perfect and simple, forgive me but how do I create a go box in Arduino?  I would love to post a simple solution here and send it to dnsExit support as well. 

I have tried:
 client.println("<form action=\"http://update.dnsexit.com/RemoteUpdate.sv?login=TomNo&password=xxxxx&host=tomand.com&myip=76.103.178.2\" method=\"post\">");
     client.println("</form>");
It gets the same "Your browser sent a request that this server could not understand" response. 
« Last Edit: September 06, 2012, 08:56:20 pm by TomNorth7 » Logged

Pura Vida

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9541
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I requested a url like below that works when it is used in a browser url box.

http://update.dnsexit.com/RemoteUpdate.sv?login=TomNo&password=xxxxx&host=tomand.com&myip=76.103.178.2
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Sonoma, California
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I appreciate your working on this.  The URL works great when pasted in Firefox.  Unfortunately I don't seem to be able to find a way to code that for the Arduino Ethernet shield.  Every GET and POST and action and <form> that I upload seems to either completely fail or I'm back to the same "server cannot understand . . . . ".  I was hopeful that maybe my escape (\") usage or HTML !DOCTYPE were at fault.  I'm pretty much out of ideas and the dnsexit company is not very interested in Arduino.  

I should add that the goal is to have a little Arduino keeping the IP current (maybe just daily updates) so I can remotely access a security camera.  There are no people or other computers available.
« Last Edit: September 06, 2012, 10:20:22 pm by TomNorth7 » Logged

Pura Vida

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9541
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Using <form> in arduino code that is making a get request is strange. Below is some test code you can try substituting your url for the one for my web site. Note that if your site uses virtual hosting, you may also need to make accomidations for that.

Code:
//zoomkat 2-13-12
//DNS and DHCP-based web client test code
//for use with IDE 1.0
//open serial monitor and send an e to test
//and to see test result
//for use with W5100 based ethernet shields
//browser equivelant URL:
// http://web.comporium.net/~shb/arduino.txt
//note that the below bug fix may be required
// http://code.google.com/p/arduino/issues/detail?id=605

#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(){
  Serial.begin(9600);
  Serial.println("DNS and DHCP-based web client test 2/13/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
  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }
  // print your local IP address:
  Serial.print("Arduino IP address: ");
  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(Ethernet.localIP()[thisByte], DEC);
    Serial.print(".");
  }
  Serial.println();
  Serial.println();
}

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.0"); //download text
    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

}
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Sonoma, California
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Strange, that would be me.  Anxious to work with this wonderful new approach, thanks,  Tom
Logged

Pura Vida

Sonoma, California
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Very nice and elegant.  Thank you !   I will incorporate your better design.
Logged

Pura Vida

Pages: [1]   Go Up
Jump to: