java.net.ConnectException after remote IP address changes

G

Gasolinera

Hello, I hope someone has ran into this before or has some insight as to how
to fix this.

I wrote a small program that connects via a raw socket connection to a
remote server. However the server's IP address is dynamic.

When my program connects for the very first time all is fine. But if the
server's IP address changes (it uses Dynamic DNS) then my program hangs with
a java.net.ConnectionException.

So my question is, is there anyway to tell the JVM to flush its
internally-stored DNS address-to-name values? I figure this is what's
happening, and that my porgram is trying to connect to the old address
because it is cached locally.

So, any ideas?

Thanks.
 
S

Sudsy

Gasolinera said:
Hello, I hope someone has ran into this before or has some insight as to how
to fix this.

I wrote a small program that connects via a raw socket connection to a
remote server. However the server's IP address is dynamic.

When my program connects for the very first time all is fine. But if the
server's IP address changes (it uses Dynamic DNS) then my program hangs with
a java.net.ConnectionException.

So my question is, is there anyway to tell the JVM to flush its
internally-stored DNS address-to-name values? I figure this is what's
happening, and that my porgram is trying to connect to the old address
because it is cached locally.

So, any ideas?

Thanks.

You can reasonably assume that any local caching by the resolver on
your client is being done according to the wishes of the authoritative
nameservers.
DNS records contain a field which define how long clients can cache
the name to address mapping, specifically the TTL (Time To Live) field
in the SOA (Start Of Authority) record.
A server which uses dynamic IP address allocation should have a TTL
which is low enough that clients don't suffer connection time-outs
when the address changes.
(Maybe there is a place for us dinosaurs in this brave new world!)
 

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

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top