You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dnsjava v2.0.8 is 12 (!) years old. Please use the latest version, which is currently v3.5.1. Also, if Lookup.run() fails, the result is null. Use getErrorString() to find out why the lookup failed.
null
network error
Process finished with exit code 0
So... in a roundabout way the error is still the same (I think?) 'network error' does sound similar to SocketTimeoutException
But I've already confirmed that we get an answer via wireshark, is there a way to get more info about the error, or somewhere I could put a break and debug the answer processing?
Please attach the debug (or trace) log output from dnsjava. It uses slf4j-api, so you can attach basically any logging framework. For your example, even slf4j-simple works. If you're using Gradle: implementation 'org.slf4j:slf4j-simple:1.7.35'
Also pass -Dorg.slf4j.simpleLogger.defaultLogLevel=debug (or trace) as a JVM argument.
This somehow looks similar to #194. However, there apparently v3.5.1 worked fine.
I took a look at #194 but its a different error to mine.
I double checked wireshark because it really looks like a networking issue, but it is the same as my original post, shows the query and the answer. It seems like somewhere it loses track of the result, I added the timing to slf4j and 5 seconds go by, but the response in wireshark is instant.
I mentioned #194 because in both cases the dnsjava's NIO implementation seems to behave differently. It's possible that the underlying async I/O on Mac is more strict than on Windows and Linux and we do something wrong.
As I don't have a modern enough Mac, this is really difficult for me to debug. Maybe @nresare can help here?
But maybe you can add some more information by:
Trying with Java 11
Taking a thread dump after the UDP message is sent, but before the resolver throws the timeout exception.
Don't know why I didn't check this fully before, but I've found the cause; PaloAlto's GlobalProtect VPN client. Although the firewall within the VPN allows the traffic, and wireshark shows the ANSWER packet get back to my local machine at the VPN tunnel utun0 interface, there is something about the VPN OS setup that messes with DNS resolution and so it 'times out'.
Closing the VPN client fully allowed Lookup.run() to complete successfully.
I tried with Java 11 with the same results.
I'm gonna follow up with my IT/GlobalProtect team, let me know if you still want that thread dump.
Thanks for the follow-up. I don't think the thread dump is relevant if it works without the VPN client. I'll close this issue for now, we can always reopen if there's more to it than the VPN.
Have had no further luck with disabling the VPN, completely removing it and any other potential blocking software seems to have no effect, the problem is back (Which makes me confused as I did see it working once and since then nothing, I have no idea why that one attempt worked.
Same issue, this time I can see on wireshark the DNS request and response go via WiFi: en0, with all VPN processes killed and double checked with ps
I upgraded to masOS 12.6 with no change.
Same result with Java 11
I'm not sure how to grab the thread dump exactly at the point the UDP request is sent, could you give me some tips?
I'm not sure how to grab the thread dump exactly at the point the UDP request is sent, could you give me some tips?
Not sure what tools you use. In IntelliJ Idea, you can click the camera symbol while debugging. Do that within the timeout, the 5s should be enough if you're prepared to click.
You can also create a thread dump via a Java API, e.g. by starting a thread, sleeping 1 or 2 seconds, then call:
@Test
fun simpleResolver() {
val r: Resolver = SimpleResolver("8.8.8.8")
val l = Lookup("google.com.", Type.A)
l.setResolver(r)
l.setCache(null)
for (i in 0..2) {
val results: Array<Record>? = l.run()
if (results != null) {
System.out.println(Arrays.asList(results))
} else {
System.out.println(l.getErrorString())
}
}
}
has the following trace debugging output
2023-01-26 17:30:36,827 DEBUG [Test worker] org.xbill.DNS.config.JndiContextResolverConfigProvider$InnerJndiContextResolverConfigProvider: JNDI class: javax.naming.directory.DirContext
2023-01-26 17:30:36,833 DEBUG [Test worker] org.xbill.DNS.config.BaseResolverConfigProvider: Added /8.8.8.8:53 to nameservers
2023-01-26 17:30:36,836 DEBUG [Test worker] org.xbill.DNS.config.BaseResolverConfigProvider: Added thesiliconvillage.com. to search paths
2023-01-26 17:30:36,838 DEBUG [Test worker] org.xbill.DNS.config.BaseResolverConfigProvider: Added /192.168.86.1:53 to nameservers
2023-01-26 17:30:36,860 DEBUG [Test worker] org.xbill.DNS.Lookup: Lookup for google.com./A, cache answer: unknown
2023-01-26 17:30:36,864 TRACE [Test worker] org.xbill.DNS.Compression: Looking for google.com., found -1
2023-01-26 17:30:36,865 TRACE [Test worker] org.xbill.DNS.Compression: Adding google.com. at 12
2023-01-26 17:30:36,865 TRACE [Test worker] org.xbill.DNS.Compression: Looking for com., found -1
2023-01-26 17:30:36,865 TRACE [Test worker] org.xbill.DNS.Compression: Adding com. at 19
2023-01-26 17:30:36,865 TRACE [Test worker] org.xbill.DNS.SimpleResolver: Sending google.com./A, id=37672 to udp/8.8.8.8:53, query:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37672
;; flags: rd ; qd: 1 an: 0 au: 0 ad: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0; flags: ; udp: 1280
;; QUESTIONS:
;; google.com., type = A, class = IN
;; ANSWERS:
;; AUTHORITY RECORDS:
;; ADDITIONAL RECORDS:
;; Message size: 39 bytes
2023-01-26 17:30:36,869 DEBUG [Test worker] org.xbill.DNS.NioClient: Starting dnsjava NIO selector thread
2023-01-26 17:30:36,882 TRACE [dnsjava NIO selector] org.xbill.DNS.NioClient: 39b (UDP write): 93 28 01 00 00 01 00 00 00 00 00 01 06 67 6F 6F 67 6C
65 03 63 6F 6D 00 00 01 00 01 00 00 29 05 00 00 00 00
00 00 00
2023-01-26 17:30:46,906 DEBUG [Test worker] org.xbill.DNS.Lookup: Lookup for google.com./A, id=37672 failed using resolver SimpleResolver [/8.8.8.8:53]
java.io.IOException: Timed out while trying to resolve google.com./A, id=37672
at org.xbill.DNS.Resolver.send(Resolver.java:170)
at org.xbill.DNS.Lookup.lookup(Lookup.java:573)
at org.xbill.DNS.Lookup.resolve(Lookup.java:653)
at org.xbill.DNS.Lookup.run(Lookup.java:666)
at com.ridgelineapps.utils.DnsTest.simpleResolver(DnsTest.kt:81)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:147)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:86)
at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103)
at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:92)
at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:86)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:217)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:213)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:138)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:68)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
at jdk.proxy1/jdk.proxy1.$Proxy2.stop(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
network error
I have the same issue with my Mac 13.6, Java 17.0.8. I see it only when I specify particular DNS server address when creating SimpleResolver. If no DNS address provided, then it works fine. dig works fine from terminal with and without DNS address.
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, #260 (comment) 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.
I can consistently reproduce this on macOS 14.2 with dnsjava 3.5.3, and similarly, setting TCP to true fixes it for me as well. This behavior extends at least as far back as dnsjava 2.1.9. Where should I start with debugging?
@nicholas-signal Create simple class that you can easily execute, like in #260 (comment). Then try to debug in NioClient and NioUdpClient if you get any events at all, try if you need to modify the selection keys. You could also try to create a very basic UDP client outside of dnsjava, send the bytes for a simple query (e.g. dumped by a previous request from dnsjava) and verify that you're actually getting results back.
Hi!
I'm using the latest version (3.5.3) to performing NAPTR query (reversed number separated by dots and concatenated with dns suffix) e.g "6.5.4.3.2.1.example.org", and I'm facing an issue with the timeout.
when I set the timeout to 2 sec for example and I send a wrong query to dns server the timeout is not respected and the resolver used the default timeout 10 sec.
here is below my code:
@mohamed-elhar You seem to have a different issue. Also, your example runs in exactly 2s when I specify an invalid IP address as the dns server. If yours is running longer, then you probably have one or more searchPaths. Use absolute names if you can.
Thank you @ibauersachs for you response.
Exactly, I've logged the searchPath using ResolveConfig.searchPath() and I confirm that I have multiple ones.
Is there any option to not use the default paths mentioned in the /etc/resolv.conf and forcing only the dns server provided in the Resolver constructor?
I've some problem with Cache mechanism, I set the max records and the ttl but each time I send an enum query I visualize in the dns server that a new query is arriving. Here is bellow the code used:
Cache cache = new Cache(DClass.IN);
cache.setMaxCache(5);
cache.setMaxNCache(5);
cache.setMaxEntries(1000);
Lookup.setDefaultCache(cache, cache.getDClass());
Lookup lookup = new Lookup(NAPTRQuery, Type.NAPTR, DClass.IN);
Record[] records = lookup.run();
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.
I experience the same issue (MacOS 14.6.1, Java 21, dnsjava 3.6.1). The application makes the DNS request over UDP, and according to tcpdump, the response arrives just fine.
There is no problem when deployed to Linux.
The Java app is not blocked by MacOS firewall.
Switching to DNS over TCP works fine.
You could also try to create a very basic UDP client outside of dnsjava, send the bytes for a simple query (e.g. dumped by a previous request from dnsjava) and verify that you're actually getting results back.
I wrote the following Go program. It takes the trace output of dnsjava and makes a request for the MX RRs of gmail.com to Quad9. It returns the DNS response just fine:
$ go run dns.go1e788180000100050000000105676d61696c03636f6d00000f0001c00c000f0001000004fa0020001404616c74320d676d61696c2d736d74702d696e016c06676f6f676c65c012c00c000f0001000004fa0009002804616c7434c02ec00c000f0001000004fa0009000a04616c7431c02ec00c000f0001000004fa00040005c02ec00c000f0001000004fa0009001e04616c7433c02e00002904d0000000000000
I also get proper responses using dig and even echo -n <dns-request-bytes> | xxd -r -p | nc -u 9.9.9.8 53. It just does not work with dnsjava.
After writing the comment directly above, I updated my Java from 21.0.x to 21.0.4, ran the application again, allowed connections to the Java app after being prompted by the MacOS firewall and voila, dnsjava can now make DNS queries over UDP again. I'm happy, but confused.
Activity
ibauersachs commentedon Aug 19, 2022
dnsjava v2.0.8 is 12 (!) years old. Please use the latest version, which is currently v3.5.1. Also, if
Lookup.run()fails, the result isnull. UsegetErrorString()to find out why the lookup failed.chris-cyberark commentedon Aug 30, 2022
@ibauersachs Thanks for the reply, I had no idea my ver was so old!
Tried again using 3.5.1, and included getErrorString():
The output is now:
So... in a roundabout way the error is still the same (I think?) 'network error' does sound similar to SocketTimeoutException
But I've already confirmed that we get an answer via wireshark, is there a way to get more info about the error, or somewhere I could put a break and debug the answer processing?
Thanks
ibauersachs commentedon Aug 30, 2022
Which Java/JDK version are you using?
Please attach the debug (or trace) log output from dnsjava. It uses slf4j-api, so you can attach basically any logging framework. For your example, even slf4j-simple works. If you're using Gradle:
implementation 'org.slf4j:slf4j-simple:1.7.35'Also pass
-Dorg.slf4j.simpleLogger.defaultLogLevel=debug(or trace) as a JVM argument.This somehow looks similar to #194. However, there apparently v3.5.1 worked fine.
chris-cyberark commentedon Sep 5, 2022
Java 1.8 (Azul 1.8_345)
I took a look at #194 but its a different error to mine.
I double checked wireshark because it really looks like a networking issue, but it is the same as my original post, shows the query and the answer. It seems like somewhere it loses track of the result, I added the timing to slf4j and 5 seconds go by, but the response in wireshark is instant.
ibauersachs commentedon Sep 7, 2022
I mentioned #194 because in both cases the dnsjava's NIO implementation seems to behave differently. It's possible that the underlying async I/O on Mac is more strict than on Windows and Linux and we do something wrong.
As I don't have a modern enough Mac, this is really difficult for me to debug. Maybe @nresare can help here?
But maybe you can add some more information by:
chris-cyberark commentedon Sep 8, 2022
Don't know why I didn't check this fully before, but I've found the cause; PaloAlto's GlobalProtect VPN client. Although the firewall within the VPN allows the traffic, and wireshark shows the ANSWER packet get back to my local machine at the VPN tunnel utun0 interface, there is something about the VPN OS setup that messes with DNS resolution and so it 'times out'.
Closing the VPN client fully allowed Lookup.run() to complete successfully.
I tried with Java 11 with the same results.
I'm gonna follow up with my IT/GlobalProtect team, let me know if you still want that thread dump.
[-]Maven repo dnsjava 2.0.8 Lookup.run returns SocketTimeoutException on MacOS 12.5[/-][+]GlobalProtect VPN causes SocketTimeoutException on MacOS 12.5[/+]ibauersachs commentedon Sep 8, 2022
Thanks for the follow-up. I don't think the thread dump is relevant if it works without the VPN client. I'll close this issue for now, we can always reopen if there's more to it than the VPN.
chris-cyberark commentedon Sep 27, 2022
Have had no further luck with disabling the VPN, completely removing it and any other potential blocking software seems to have no effect, the problem is back (Which makes me confused as I did see it working once and since then nothing, I have no idea why that one attempt worked.
Same issue, this time I can see on wireshark the DNS request and response go via WiFi: en0, with all VPN processes killed and double checked with ps
I upgraded to masOS 12.6 with no change.
Same result with Java 11
I'm not sure how to grab the thread dump exactly at the point the UDP request is sent, could you give me some tips?
ibauersachs commentedon Oct 2, 2022
Not sure what tools you use. In IntelliJ Idea, you can click the camera symbol while debugging. Do that within the timeout, the 5s should be enough if you're prepared to click.

You can also create a thread dump via a Java API, e.g. by starting a thread, sleeping 1 or 2 seconds, then call:
@nresare You have a Mac. Could you maybe do some debugging?
[-]GlobalProtect VPN causes SocketTimeoutException on MacOS 12.5[/-][+]SocketTimeoutException on MacOS >= 12.5[/+]kevinchan-rl commentedon Jan 27, 2023
Hi, I am seeing similar problem with:
has the following trace debugging output
dig works fine
Any ideas? I am unable to disable my corporate VPN but will try to find a way to do that and try again.
16 remaining items
dsukhoroslov commentedon Oct 11, 2023
I have the same issue with my Mac 13.6, Java 17.0.8. I see it only when I specify particular DNS server address when creating SimpleResolver. If no DNS address provided, then it works fine. dig works fine from terminal with and without DNS address.
ibauersachs commentedon Oct 27, 2023
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, #260 (comment) 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.
nicholas-signal commentedon Dec 19, 2023
I can consistently reproduce this on macOS 14.2 with dnsjava 3.5.3, and similarly, setting TCP to
truefixes it for me as well. This behavior extends at least as far back as dnsjava 2.1.9. Where should I start with debugging?ibauersachs commentedon Jan 2, 2024
@nicholas-signal Create simple class that you can easily execute, like in #260 (comment). Then try to debug in
NioClientandNioUdpClientif you get any events at all, try if you need to modify the selection keys. You could also try to create a very basic UDP client outside of dnsjava, send the bytes for a simple query (e.g. dumped by a previous request from dnsjava) and verify that you're actually getting results back.mohamed-elhar commentedon Jan 5, 2024
Hi!
I'm using the latest version (3.5.3) to performing NAPTR query (reversed number separated by dots and concatenated with dns suffix) e.g "6.5.4.3.2.1.example.org", and I'm facing an issue with the timeout.
when I set the timeout to 2 sec for example and I send a wrong query to dns server the timeout is not respected and the resolver used the default timeout 10 sec.
here is below my code:
Can you please help?
Thanks in advance.
ibauersachs commentedon Jan 5, 2024
@mohamed-elhar You seem to have a different issue. Also, your example runs in exactly 2s when I specify an invalid IP address as the dns server. If yours is running longer, then you probably have one or more searchPaths. Use absolute names if you can.
mohamed-elhar commentedon Jan 5, 2024
Thank you @ibauersachs for you response.
Exactly, I've logged the searchPath using ResolveConfig.searchPath() and I confirm that I have multiple ones.
Is there any option to not use the default paths mentioned in the /etc/resolv.conf and forcing only the dns server provided in the Resolver constructor?
ibauersachs commentedon Jan 5, 2024
You can clear the path on your resolver instance, otherwise have a look at the config properties as described in the readme.
mohamed-elhar commentedon Jan 8, 2024
I've some problem with Cache mechanism, I set the max records and the ttl but each time I send an enum query I visualize in the dns server that a new query is arriving. Here is bellow the code used:
ibauersachs commentedon Jan 9, 2024
Your problem has nothing to do with the Mac issue here. Please open separate issues so that people following here are not further distracted.
osxhacker commentedon Mar 6, 2024
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!
svandenakker commentedon Aug 21, 2024
I experience the same issue (MacOS 14.6.1, Java 21,
dnsjava3.6.1). The application makes the DNS request over UDP, and according totcpdump, the response arrives just fine.I wrote the following Go program. It takes the
traceoutput ofdnsjavaand makes a request for theMXRRs ofgmail.comto Quad9. It returns the DNS response just fine:I also get proper responses using
digand evenecho -n <dns-request-bytes> | xxd -r -p | nc -u 9.9.9.8 53. It just does not work withdnsjava.svandenakker commentedon Aug 21, 2024
After writing the comment directly above, I updated my Java from 21.0.x to 21.0.4, ran the application again, allowed connections to the Java app after being prompted by the MacOS firewall and voila,
dnsjavacan now make DNS queries over UDP again. I'm happy, but confused.