8000 Behavior of ExtendedResolver.setTimeout · Issue #206 · dnsjava/dnsjava · GitHub
[go: up one dir, main page]

Skip to content
Behavior of ExtendedResolver.setTimeout #206
Closed
@ulixcode-labs

Description

@ulixcode-labs

Hi,

I am trying to resolve domain names to ip with timeout. I set the timeout in resolver, however, looks like the timeout be ignored?
I tried many times, the time elapsed measured is around 50 ms on my setup.
Looks like it ignore the resolver timeout ? Is there anything wrong with my code?

import org.xbill.DNS.*;

public class eee {
    public static void main(String[] args) {

        Resolver r1 = null;
        try {
            String [] resolvers = new String [] {
                    "1.1.1.1",
                    "8.8.8.8",
                    "8.8.4.4"
            };
            r1 = new ExtendedResolver(resolvers);
            r1.setTimeout(0, 20);
        } catch (Exception e) {}

        Lookup l = null;
        org.xbill.DNS.Record[] records = null;

        String s = "github.com";
        try {
            l = new Lookup(s);
            l.setResolver(r1);
        } catch (Exception e) {}

        long start = System.currentTimeMillis();

        try {
            records = l.run();
        } catch (Exception e) {}

        System.out.println(System.currentTimeMillis()-start);
        String ip;
        if (records != null && records.length != 0) {
            String[] ans = records[0].toString().split("\t");
            ip = ans[ans.length - 1];
            System.out.println(ip);
        }
    }
}

output:
54
192.30.255.113

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0