----- Original Message -----
From: "Tim C." <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, March 17, 2003 13:38
Subject: Catching Exceptions from incorrect proxy setting


>
> I keep returning to the same problem of trying to find a way of allowing a
> user on the client side to determine proxy settings. It seems if they
> define:
>
>    System.setProperty("proxySet", "true" );
>    System.setProperty("http.proxyPort",8080);
>    System.setProperty("http.proxyHost",wwcache.blah);
>
> before the first call is invoked it works. The problem comes when the
wrong
> proxy settings are given and the exception is caught. If the correct proxy
> settings are then tried and a second call made to the server then it fails
> with the same exception (java.net.UnknownHostException).


the JRE caches hostname to IP mappings, possibly to stop you subverting
applet security by fiddling with DNS records. However, they also cache
negative entries, in complete violation of the DNS specification. They say
"negative caching is used to improve performance.", but this is so bogus it
hurts. Who cares about the performance hit of looking up nonexistent hosts.
I have been burned by this on long-lived server code; upstream DNS goes down
for a bit and suddenly your server wont talk to the database till you
restart it.

Look up java.net.InetAddress for info on properties to set to control
caching. These must be set *before* the JVM starts (on the command line),
and they are different in Java1.4 from the prior versions, as are the
defaults. Java1.4 claims a 10 sec cache on negative DNS, Java1.3 appears to
hang on to negative lookups until shortly before the heat death of the
universe.


Reply via email to