Go Down

Topic: no-ip and Arduino Ethernet Shield (Read 11038 times) previous topic - next topic

Quick

I would like to have my Arduino update my no-ip host. I have created this code based on the API published by no-ip: http://www.no-ip.com/integrate/request/

Below is my code and the output on the serial monitor. According to the no-ip API documentation, the server should provide a response, but I have been unable to get one. I believe my mistake must be somewhere in the http get request or in reading the response. Any help is appreciated. I would just like to be able to get a response, even if it is an error response.

Code:
Quote
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x04, 0x16 };
char noipServer[] = "https://dynupdate.no-ip.com";

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 initilize:
  delay(2000);
 
  if(client.connect(noipServer, 80)){
    Serial.println("Connected to noip");
   
    client.println("GET /nic/update?hostname=johndoe.no-ip.org HTTP/1.0");
    client.println("Host: dynupdate.no-ip.com");
    client.println("Authorization: john.doe@gmail.com:mypassword");
    client.println("User-Agent: Johns Arduino Client/0.0 john.doe@gmail.com");
    client.println();
   
   
    //Wait for response
    delay(5000);
    Serial.print("Characters available: ");
    Serial.println(client.available());
   
    while(client.available() > 0)
    {
      char read_char = client.read();
      Serial.print(read_char);
    }
  }
}

void loop() {

}


Output:
Quote
Connected to noip
Characters available: 0

SurferTim

You are not waiting for the server to respond correctly. Try this.
Code: [Select]
//Wait for response

   while(client.connected())
   {   
      // stay in this loop until the server closes the connection

       while(client.available())
       {
         // The server will not close the connection until it has sent the last packet
         // and this buffer is empty

         char read_char = client.read();
         Serial.write(read_char);
       }
   }
   // close your end after the server closes its end
   client.stop();


robtillaart

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

zoomkat

I'm testing the no-ip update protocol, but have not received a status reply from the no-ip server.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

braindamaged

I don't have an ethernet shield so forgive me if my info is redundant or irrelevant.
If your ultimate goal is just making your dynamic IP behave as static by using a dynamic DNS service then you can also use dnsexit.com.

This url has to be accessed by the device whose current IP you want to reflect on the DNS.
The user just has to open the following url
Code: [Select]
http://www.dnsexit.com/RemoteUpdate.sv?login=youUsername&password=yourPassword&host=rourHostName&myip=

Quick

I changed my code to reflect SuferTim's suggestion, but it still did not work. The server terminated the connection without sending anything back. I might have to contact no-ip support and figure out what is going on.

I tried putting this into the URL bar on my browser:
https://dynupdate.no-ip.com/nic/update?hostname=johndoe.no-ip.org HTTP/1.0

(With my actual host name of course)
And I was presented with a prompt for a user name and password. After entering that I was given a blank webpage with one of their response codes on it. The code was "nohost" which I thought was odd because I provided the proper info. But at least I got a response.

I am not an HTTP expert though, zoomkat, maybe you could try this? Maybe you will see something that I overlooked because I don't really know what I am doing.

EDIT: braindamage posted while I was writing this post. Thanks for the link. I will check it out. That sounds a lot easier.

braindamaged

Here is a link to the developer's doc of dnsexit http://downloads.dnsexit.com/ipUpdate.doc.
Maybe you can find some more info here

SurferTim

I did not notice at first, but you will not get a response because the web client/server code does not support SSL (port 443) connections.
https://dynupdate.no-ip.com/nic/update?hostname=johndoe.no-ip.org

doughboy

first, noipServer[] should just be dynupdate.no-ip.com, you don't need the https part.

second, from the protocol description, you need to send this

GET /nic/update?hostname=mytest.testdomain.com&myip=1.2.3.4 HTTP/1.0
Host: dynupdate.no-ip.com
Authorization: Basic base64-encoded-auth-string
User-Agent: Bobs Update Client WindowsXP/1.2 bob@somedomain.com

note the Authorization header MUST be base64 or UUencoded. You are sending in clear text. You need to search for code to do the encoding and add it to your program.

jerry

zoomkat

Quote
note the Authorization header MUST be base64 or UUencoded. You are sending in clear text.


Then why does the no-ip api page say the below? Also the "&myip=1.2.3.4" may cause a failure if an inappropriate IP address is used. Probably best left off.

"base64-encoded-auth-string should be the base64 encoding of username:password. Un-encoded strings are accepted as well."
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

doughboy


That is exactly what I am saying, the authorization header string must be base64 or uu encoded.

http://www.w3.org/Protocols/HTTP/1.0/spec.html#BasicAA

myip is optional because the server can figure out your ip from the socket object.

zoomkat

Quote
That is exactly what I am saying, the authorization header string must be base64 or uu encoded.


Hmmm, in my world there is a distinct difference between "Un-encoded" and "uu encoded". In the real technical world assuming they are the same is why airplanes fall out of the sky and such.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

doughboy


zoomkat

Some of the stuff on the no-ip page just doesn't make scense, like the below statement.


An example update request string
http://username:password@dynupdate.no-ip.com/nic/update?
hostname=mytest.testdomain.com&myip=1.2.3.4
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

SurferTim

This is from another thread. Maybe that will help.
http://arduino.cc/forum/index.php/topic,89911.msg677148.html#msg677148


Your authentication should look something like this:
Code: [Select]
client.write(
"GET /camera_control.cgi?user=user&password=password&command=<command> HTTP/1.0\r\n"
"Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\r\n"
"\r\n");


You can use this website to encode your USERNAME:PASSWORD in base64:

        http://www.opinionatedgeek.com/dotnet/tools/base64encode/

For this example, "Aladdin:open sesame" has been encoded as "QWxhZGRpbjpvcGVuIHNlc2FtZQ==".



Go Up