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: image

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 37 (15 by maintainers)

Commits related to this issue

Most upvoted comments

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:

$ uname -mrs
Darwin 23.1.0 arm64

$ java -version
openjdk version "19.0.2" 2023-01-17
OpenJDK Runtime Environment (build 19.0.2+7-44)
OpenJDK 64-Bit Server VM (build 19.0.2+7-44, mixed mode, sharing)

All dnsjava tests passed when mvn test was executed on the release/3.5.x branch. However, ResolveExample.java exhibited the query timeout symptoms both when SimpleResolver and ValidatingResolver were used.

Resolution

Downloading OpenJDK 21 for macOS / AArch64, installing it, then using it to do a full recompile resulted in ResolveExample.java running without exception. The output also appeared to be in order.

Rebuilding the project I am working on with JDK v21 which uses dnsjava and 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:

$ java -version
openjdk version "21.0.2" 2024-01-16
OpenJDK Runtime Environment (build 21.0.2+13-58)
OpenJDK 64-Bit Server VM (build 21.0.2+13-58, mixed mode, sharing)

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.