dnsjava: SocketTimeoutException on MacOS >= 12.5
Maven repo dnsjava 2.0.8 Lookup.run returns SocketTimeoutException on MacOS 12.5 Using some basic DNS test code:
import org.xbill.DNS.*;
import java.util.*;
...
Options.set("verbose", "true");
Lookup look = new Lookup("google.com");
String looked = Arrays.toString(look.run());
System.out.println(looked);
I get the result:
adding server <dns server IP>
lookup google.com. A
unknown
Sending to <dns server IP>:53
ExtendedResolver: got java.net.SocketTimeoutException
I can see in wireshark that there is a response from the DNS server, it seems it is not parsed by dnsjava:

About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 37 (15 by maintainers)
Commits related to this issue
- Extend logging in NIO clients to trace bugs Related to #194, #260 and #267 — committed to dnsjava/dnsjava by ibauersachs 4 years ago
- Extend logging in NIO clients to trace bugs Related to #194, #260 and #267 — committed to dnsjava/dnsjava by ibauersachs 4 years ago
Hi @ibauersachs ,
Here is a follow-up for anyone encountering this issue as of today, along with what rectified this problem.
Problem Verification
I ran into the same problem today using the following:
All
dnsjavatests passed whenmvn testwas executed on therelease/3.5.xbranch. However,ResolveExample.javaexhibited the query timeout symptoms both whenSimpleResolverandValidatingResolverwere used.Resolution
Downloading OpenJDK 21 for
macOS / AArch64, installing it, then using it to do a full recompile resulted inResolveExample.javarunning without exception. The output also appeared to be in order.Rebuilding the project I am working on with JDK v21 which uses
dnsjavaand running its integration tests also no longer experience “query timeouts” and performed a successful query (which it had not before).The only change in system environment was installing and then using JDK v21.
Therefore, I believe updating to:
Rectified this issue. Should I observe this to not be the case, I will update this comment accordingly.
It is unknown if JDK v20 also rectifies this issue as I did not test that distribution.
Thanks for your work on this project!
I’ve now tried to debug this with my colleague @mkretz from @bespinian, on MacOS 14.6 with Java 11.0.21 (aarch). We were unable to reproduce the issue.
Sorry, but I’m lost here. Someone who still experiences this issue needs to debug this. Also, https://github.com/dnsjava/dnsjava/issues/260#issuecomment-1406937650 makes me wonder whether this really is a dnsjava issue or something in either the JVM or some other VPN or firewall tool/extension that blocks the Java process from getting the reply.