0

I try to update my DDNS (No-IP) in a android client.

I make a request to the following URL.(Discription)

http://username:password@dynupdate.no-ip.com/nic/update?hostname=mytest.testdomain.com&myip=1.2.3.4

When i am using my webbrowser, everything works fine.

"good [ip-address]"

But my android client only gets the response "nochange"

 URL url = new URL("http://" + USERNAME + ":" + PASSWORD + "@dynupdate.no-ip.com/nic/update?hostname=" + HOSTNAME + "&myip=" + IP_ADDRESS);
 HttpURLConnection conn = (HttpURLConnection) url.openConnection();
 conn.setRequestMethod("GET");
 int i = conn.getResponseCode();
 stringBuilder = new StringBuilder();
 bufferedReader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));String line;
 while ((line = bufferedReader.readLine()) != null) {
   stringBuilder.append(line + "\n");
 }
Anil_M
  • 10,893
  • 6
  • 47
  • 74

1 Answers1

0

From http://www.noip.com/integrate/request:

When making an update it is important that your http request include an HTTP User-Agent to help No-IP identify different clients that access the system. Clients that do not supply a User-Agent risk being blocked from the system.

So you'll probably need to set the UserAgent as described on that page, specifically, something like this (replace these details with the datails of your own app):

User-Agent: NameOfUpdateProgram/VersionNumber maintainercontact@domain.com

See here for details of how to set the UserAgent when using HttpUrlConnection, something like this should work:

HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
hc.setRequestProperty("User-Agent", "NameOfUpdateProgram/VersionNumber maintainercontact@domain.com");
Community
  • 1
  • 1
Jonas Czech
  • 12,018
  • 6
  • 44
  • 65
  • Adding the user-agend has no effects, the problem still exists. I tried to make the requst with the android browser and everything works fine (i think the browser has his own user-agent) – Johnny Cash Apr 01 '16 at 13:38
  • @JohnnyCash, In that case, I have no idea what else could be wrong, sorry – Jonas Czech Apr 01 '16 at 13:39