Skip to content

SocketTimeoutException on MacOS >= 12.5 #260

Open

Description

@chris-cyberark

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

Activity

  1. ibauersachs commented on Aug 19, 2022

    @ibauersachs
    Member

    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.

  2. chris-cyberark commented on Aug 30, 2022

    @chris-cyberark
    Author

    @ibauersachs Thanks for the reply, I had no idea my ver was so old!
    Tried again using 3.5.1, and included getErrorString():

    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);
            System.out.println(look.getErrorString());
    

    The output is now:

    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?

    Thanks

  3. ibauersachs commented on Aug 30, 2022

    @ibauersachs
    Member

    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.

  4. chris-cyberark commented on Sep 5, 2022

    @chris-cyberark
    Author

    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.

    > Task :DnsApplication.main()
    16 [main] DEBUG org.xbill.DNS.config.JndiContextResolverConfigProvider$InnerJndiContextResolverConfigProvider - JNDI class: javax.naming.directory.DirContext
    26 [main] DEBUG org.xbill.DNS.config.ResolvConfResolverConfigProvider - Added /<dns server>:53 to nameservers
    139 [main] DEBUG org.xbill.DNS.Lookup - Lookup for google.com./A, cache answer: unknown
    159 [main] DEBUG org.xbill.DNS.ExtendedResolver - Sending google.com./A, id=26250 to resolver 0 (SimpleResolver [/<dns server>:53]), attempt 1 of 3
    160 [main] TRACE org.xbill.DNS.Compression - Looking for google.com., found -1
    161 [main] TRACE org.xbill.DNS.Compression - Adding google.com. at 12
    161 [main] TRACE org.xbill.DNS.Compression - Looking for com., found -1
    161 [main] TRACE org.xbill.DNS.Compression - Adding com. at 19
    162 [main] TRACE org.xbill.DNS.SimpleResolver - Sending google.com./A, id=26250 to udp/<dns server>:53, query:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 26250
    ;; 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
    168 [main] DEBUG org.xbill.DNS.NioClient - Starting dnsjava NIO selector thread
    176 [dnsjava NIO selector] TRACE org.xbill.DNS.NioClient - 39b (UDP write):	66 8A 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 
    
    5182 [dnsjava NIO selector] DEBUG org.xbill.DNS.ExtendedResolver - Failed to resolve google.com./A, id=26250 with resolver 0 (SimpleResolver [/<dns server>:53]) on attempt 1 of 3, reason=java.net.SocketTimeoutException: Query timed out
    5183 [dnsjava NIO selector] DEBUG org.xbill.DNS.ExtendedResolver - Sending google.com./A, id=26250 to resolver 0 (SimpleResolver [/<dns server>:53]), attempt 2 of 3
    5183 [dnsjava NIO selector] TRACE org.xbill.DNS.Compression - Looking for google.com., found -1
    5183 [dnsjava NIO selector] TRACE org.xbill.DNS.Compression - Adding google.com. at 12
    5183 [dnsjava NIO selector] TRACE org.xbill.DNS.Compression - Looking for com., found -1
    5183 [dnsjava NIO selector] TRACE org.xbill.DNS.Compression - Adding com. at 19
    5183 [dnsjava NIO selector] TRACE org.xbill.DNS.SimpleResolver - Sending google.com./A, id=26250 to udp/<dns server>:53, query:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 26250
    ;; 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
    5184 [dnsjava NIO selector] TRACE org.xbill.DNS.NioClient - 39b (UDP write):	66 8A 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 
    
    10182 [main] DEBUG org.xbill.DNS.Lookup - Lookup for google.com./A, id=26250 failed using resolver ExtendedResolver of [SimpleResolver [/<dns server>:53]]
    java.io.IOException: Timed out while trying to resolve google.com./A, id=26250
    	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:671)
    	at com.dnstest.dns.DnsApplication.main(DnsApplication.java:11)
    
  5. ibauersachs commented on Sep 7, 2022

    @ibauersachs
    Member

    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.
  6. chris-cyberark commented on Sep 8, 2022

    @chris-cyberark
    Author

    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.

  7. changed the title [-]Maven repo dnsjava 2.0.8 Lookup.run returns SocketTimeoutException on MacOS 12.5[/-] [+]GlobalProtect VPN causes SocketTimeoutException on MacOS 12.5[/+] on Sep 8, 2022
  8. ibauersachs commented on Sep 8, 2022

    @ibauersachs
    Member

    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.

  9. chris-cyberark commented on Sep 27, 2022

    @chris-cyberark
    Author

    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?

  10. ibauersachs commented on Oct 2, 2022

    @ibauersachs
    Member

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

    You can also create a thread dump via a Java API, e.g. by starting a thread, sleeping 1 or 2 seconds, then call:

    ThreadMXBean bean = ManagementFactory.getThreadMXBean();
    ThreadInfo[] infos = bean.dumpAllThreads(true, true);
    System.out.println(Arrays.stream(infos).map(Object::toString).collect(Collectors.joining()));
    

    @nresare You have a Mac. Could you maybe do some debugging?

  11. changed the title [-]GlobalProtect VPN causes SocketTimeoutException on MacOS 12.5[/-] [+]SocketTimeoutException on MacOS >= 12.5[/+] on Oct 2, 2022
  12. kevinchan-rl commented on Jan 27, 2023

    @kevinchan-rl

    Hi, I am seeing similar problem with:

    • macOS Monterey 12.6.2
    • JDK is Amazon Corretto-17.0.4.8.1
    • netskope VPN
    • dnsjava 3.5.2
    • kotlin 1.7.21
        @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
    

    dig works fine

    % dig @8.8.8.8 google.com     
    
    ; <<>> DiG 9.10.6 <<>> @8.8.8.8 google.com
    ; (1 server found)
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62053
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
    
    ;; OPT PSEUDOSECTION:
    ; EDNS: version: 0, flags:; udp: 512
    ;; QUESTION SECTION:
    ;google.com.			IN	A
    
    ;; ANSWER SECTION:
    google.com.		300	IN	A	142.250.191.46
    
    ;; Query time: 49 msec
    ;; SERVER: 8.8.8.8#53(8.8.8.8)
    ;; WHEN: Thu Jan 26 17:39:06 PST 2023
    ;; MSG SIZE  rcvd: 55
    

    Any ideas? I am unable to disable my corporate VPN but will try to find a way to do that and try again.

  13. 16 remaining items

  14. dsukhoroslov commented on Oct 11, 2023

    @dsukhoroslov

    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.

  15. ibauersachs commented on Oct 27, 2023

    @ibauersachs
    Member

    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.

  16. nicholas-signal commented on Dec 19, 2023

    @nicholas-signal

    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?

  17. ibauersachs commented on Jan 2, 2024

    @ibauersachs
    Member

    @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.

  18. mohamed-elhar commented on Jan 5, 2024

    @mohamed-elhar

    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:

            String NAPTRQuery = "6.5.4.3.2.1.example.org";
            Resolver resolver = new SimpleResolver(dnsServerIP);
            resolver.setPort(dnsServerPort);
            resolver.setTimeout(Duration.ofMillis(2000L)); 
            Lookup lookup = new Lookup(NAPTRQuery , Type.NAPTR, DClass.IN);
            lookup.setResolver(resolver);
            lookup.setCache(new Cache());
            Record[] records = lookup.run();

    Can you please help?
    Thanks in advance.

  19. ibauersachs commented on Jan 5, 2024

    @ibauersachs
    Member

    @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.

  20. mohamed-elhar commented on Jan 5, 2024

    @mohamed-elhar

    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?

  21. ibauersachs commented on Jan 5, 2024

    @ibauersachs
    Member

    You can clear the path on your resolver instance, otherwise have a look at the config properties as described in the readme.

  22. mohamed-elhar commented on Jan 8, 2024

    @mohamed-elhar

    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();
    
  23. ibauersachs commented on Jan 9, 2024

    @ibauersachs
    Member

    Your problem has nothing to do with the Mac issue here. Please open separate issues so that people following here are not further distracted.

  24. osxhacker commented on Mar 6, 2024

    @osxhacker

    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!

  25. svandenakker commented on Aug 21, 2024

    @svandenakker

    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:

    func main() {
    	conn, err := net.Dial("udp", "9.9.9.9:53")
    	if err != nil {
    		panic(err)
    	}
    	payload := []byte{0x1E, 0x78, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x05, 0x67, 0x6D, 0x61, 0x69, 0x6C, 0x03, 0x63, 0x6F, 0x6D, 0x00, 0x00, 0x0F, 0x00, 0x01, 0x00, 0x00, 0x29, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
    	n, err := conn.Write(payload)
    	if err != nil {
    		panic(err)
    	}
    	if n <= 0 {
    		log.Fatal("no bytes WRITTEN to socket")
    	}
    	result := make([]byte, 2048)
    	n, err = conn.Read(result)
    	if err != nil {
    		panic(err)
    	}
    	if n <= 0 {
    		log.Fatal("no bytes READ from socket after 10 secs")
    	}
    	fmt.Println(hex.EncodeToString(result[:n]))
    }
    $ go run dns.go
    1e788180000100050000000105676d61696c03636f6d00000f0001c00c000f0001000004fa0020001404616c74320d676d61696c2d736d74702d696e016c06676f6f676c65c012c00c000f0001000004fa0009002804616c7434c02ec00c000f0001000004fa0009000a04616c7431c02ec00c000f0001000004fa00040005c02ec00c000f0001000004fa0009001e04616c7433c02e00002904d0000000000000

    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.

  26. svandenakker commented on Aug 21, 2024

    @svandenakker

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions