Pages: [1] 2   Go Down
Author Topic: no-ip and Arduino Ethernet Shield  (Read 9687 times)
0 Members and 1 Guest are viewing this topic.
Texas
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5986
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You are not waiting for the server to respond correctly. Try this.
Code:
//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();
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 216
Posts: 13673
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

interesting - bookmarked!
Logged

Rob Tillaart

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

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

I'm testing the no-ip update protocol, but have not received a status reply from the no-ip server.
Logged

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

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
http://www.dnsexit.com/RemoteUpdate.sv?login=youUsername&password=yourPassword&host=rourHostName&myip=
Logged

Texas
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5986
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

SF Bay area
Offline Offline
Sr. Member
****
Karma: 3
Posts: 268
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

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

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."
Logged

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

SF Bay area
Offline Offline
Sr. Member
****
Karma: 3
Posts: 268
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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.
Logged

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

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.
Logged

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

SF Bay area
Offline Offline
Sr. Member
****
Karma: 3
Posts: 268
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok. gotcha. I stand corrected.

Logged

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

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
Logged

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

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5986
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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==".

Logged

Pages: [1] 2   Go Up
Jump to: