16

Two traps in java.net.http.HttpClient that bite when you route it through a proxy, because neither one looks like a proxy problem at first.

Basic proxy auth is disabled for HTTPS tunnels by default, so your username and password can be perfectly right and the tunnel still fails on auth.

The nastier one: point it at a SOCKS proxy and it gets ignored, so requests leave from the machine's own address. No exception, no warning. Everything looks fine until you check the exit IP, and by then the job may have run for a week from your server.

So whatever client you use, I'd log the exit IP once at startup and fail the run if it matches the host's address. It's a few lines and it catches this whole family of mistakes.

Disclosure: we run a proxy service, this came out of comparing proxy support across languages.

no comments (yet)
sorted by: hot top new old
there doesn't seem to be anything here
this post was submitted on 07 Nov 2026
16 points (94.4% liked)

Java

2066 readers
1 users here now

For discussing Java, the JVM, languages that run on the JVM, and other related technologies.

founded 3 years ago
MODERATORS