Show IP address of host in ConnectException
Alan Bateman
Alan.Bateman at oracle.com
Fri Jul 21 10:33:40 UTC 2023
On 21/07/2023 10:32, Andrey Turbanov wrote:
> Hello.
>
> Recently I was struggling with troubleshooting the Socket connection
> to a server via DNS address.
> There were multiple IPs assigned to the same DNS address and I wanted
> to know exactly which IP java is trying to connect.
> Unfortunately default ConnectException doesn't show anything useful in
> the exception message
>
> java.net.ConnectException: Connection refused
>
> Even if I enable enhanced exception info
> '-Djdk.includeInExceptions=hostInfo' I still only get the DNS address
> in the exception message.
>
> java.net.ConnectException: Connection timed out: connect:
> myprod-app.global.mycompany.ro:5001
>
> Is it possible to enhance the exception message to show used IP too?
> Perhaps guarged with another JVM option.
> I think it would be very useful for troubleshooting.
>
Which JDK release is still? I thought it was changed in JDK-8299827 to
include the IP address.
-Alan
More information about the net-dev
mailing list