ju4n
ju4n

Reputation: 11

Update DNS from Java (Similar to DUC NO - IP). [Was: Actualizar DNS desde Java (Similar a DUC No-Ip)]

Days ago I try to make an application similar to No-IP DUC (Dynamic DNS Update Clients) in java but I have presented a problem and not how to fix ... Now I can retrieve the domains I have registered with the following line of code:

URLConnection conexion = new URL( "http://dynupdate.no-ip.com/list-hosts.php?email="+USER+"&pass="+PASSWORD ).openConnection();

but when I update with the following URL you recommend on page http://www.no-ip.com/integrate/request, I get an exception ...

URLConnection conexion = new URL( "http://"+USER+":"+PASSWORD+"@dynupdate.no-ip.com/nic/update?hostname="+DOMAIN+"&myip="+IP ).openConnection();

The strange thing is that manually copy the URL in the address, the update is done without problem ... If anyone can help me I appreciate it a lot ...

Upvotes: 1

Views: 1745

Answers (1)

Konoha
Konoha

Reputation: 337

Well I faced this situation as well. Found out the reason for this error is that we are using an email address for the username. The "@" present inside it conflicts with the resulting url. Try to use URLEncode to encode the username and the password part.

String username = URLEncoder.encode("[email protected]", "UTF-8");
String password = URLEncoder.encode("password", "UTF-8");
URL url = new URL( "http://"+username+":"+password+"@dynupdate.no-ip.com/nic/update?hostname="+hostname+"&myip="+ip);           
URLConnection urlConnection = url.openConnection();

Upvotes: 1

Related Questions