Problem with java and Domain Name Resolution

L

Lars Both

Hi Everybody,

I have a really annoying problem. I've implemented an application, which
connects to a server, which IP does change rather often. I came upon the
problem, that my application would not connect to the server after it's IP
has changed.
I did some investigation and found out, that the default time for
dns-caching is infinite. And I found the property, that is supposed to
change it:

java.security.Security.setProperty("networkaddress.cache.ttl" , "0");

But it did not seem to change anything. I am still stuck with my problem.
I have to restart my application everytime the server gets a new ip.

Has anybody got experience with that?

Regards
LArs
 
M

Martin Gregorie

Lars said:
Hi Everybody,

I have a really annoying problem. I've implemented an application, which
connects to a server, which IP does change rather often. I came upon the
problem, that my application would not connect to the server after it's
IP has changed.
I did some investigation and found out, that the default time for
dns-caching is infinite. And I found the property, that is supposed to
change it:

java.security.Security.setProperty("networkaddress.cache.ttl" , "0");

But it did not seem to change anything. I am still stuck with my
problem. I have to restart my application everytime the server gets a
new ip.

Has anybody got experience with that?
The really interesting TTL is the value set in the master zone file for
the server's domain. If that's set long in relation to the rate at which
the server changes its IP then you're in deep doo-doo.

Your attempt to set the TTL can at most affect your local cache. It
doesn't affect the master DNS or any additional caches between that and
the local cache. These caches expire their cache entry using the TTL set
by the master domain.

How often does your client close and re-open its server connection? How
does that compare with the rate at which the server changes IP?
 
L

Lars Both

I did some investigation and found out, that the default time for
The really interesting TTL is the value set in the master zone file for
the server's domain. If that's set long in relation to the rate at which
the server changes its IP then you're in deep doo-doo.

Your attempt to set the TTL can at most affect your local cache. It
doesn't affect the master DNS or any additional caches between that and
the local cache. These caches expire their cache entry using the TTL set
by the master domain.

How often does your client close and re-open its server connection? How
does that compare with the rate at which the server changes IP?

Hi Martin!

Thank you for your answer! The answer to the questions you asked are:

- The server changes maybe once a day and may as well be offline for days.
It is a moving server for a demo application and therefore uses a dial up
line.
- Even after days, my client is not able to reconnect. I have to restart
the application, afterwards it does work..
- I can see, that the server-name (it's a dynamic IP hoster) is resolved
accurately on that machine.

If you take all this into account, can you maybe give me another hint?

Regards
Lars
 
M

Martin Gregorie

Lars said:
Hi Martin!

Thank you for your answer! The answer to the questions you asked are:

- The server changes maybe once a day and may as well be offline for
days. It is a moving server for a demo application and therefore uses a
dial up line.
- Even after days, my client is not able to reconnect. I have to restart
the application, afterwards it does work..
>
Sounds to me as if your client should close and reopen the connection
more often.

You don't say anything about the application protocol used to talk to
the server, but if its uses request/response message pairs the simplest
approach would be to connect, send the request, read the response and
disconnect every time. A slightly more complex solution would drop the
connection after x minutes of client inactivity and reconnect when the
next request is to be sent.
 
L

Lars Both

I did some investigation and found out, that the default time for
dns-caching is infinite. And I found the property, that is supposed to
change it:

java.security.Security.setProperty("networkaddress.cache.ttl" , "0");

But it did not seem to change anything. I am still stuck with my
problem. I have to restart my application everytime the server gets a
new ip.

I recently found the solution and wanted to complete this thread by
providing it. Finally I solved my problem by changing the mentioned
property in the java.security-file which I was not aware of before. (D'oh!)

We are using a heterogenous enviroment, so that I could observe the
following:

Using Java 1.5.0_09 on Linux results in the property set at runtime being
ignored. The same holds for Java 1.4.2_08 on Linux.
The same code executed with Java 1.6.0 running on Windows works fine (the
ttl is correctly set and the domain name resolution is done properly).

I am not going to examine it beyond this point, just wanted to share.

Regards
Lars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top