InetAddress.getByName(ipAddress).getLocalHost().getCanonicalHostName();
The above line takes around 10seconds to execute.
I added the IP and hostname in etc\hosts file and still there is no change.
How does getCanonicalHostName work? Can I get the implementation of that method?
How do I increase the efficiency of this line of code?
In my case the problem was caused by the Npcap driver, which I use for Wireshark. Disabling Npcap Loopback Adapter
in Windows Control Panel\Network and Internet\Network Connections
fixed the 9 seconds delay that I had.
The delay itself happens in the Inet6AddressImpl.getHostByAddr(byte[] addr)
method (called by InetAddress.getCanonicalHostName()
), which is native, so it's hard to say what's going on other than it's DNS related.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With