Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kademlia connect to peer by dns address #22

Closed
bokoto000 opened this issue Mar 31, 2023 · 5 comments
Closed

Kademlia connect to peer by dns address #22

bokoto000 opened this issue Mar 31, 2023 · 5 comments

Comments

@bokoto000
Copy link

We have a predefined list of nodes that we must connect to. We’re bootstrapping using Kademlia. However, we encounter an error when passing the address of the node.

Exception in thread "main" java.util.concurrent.CompletionException: org.xbill.DNS.lookup.NoSuchDomainException
	at java.base/java.util.concurrent.CompletableFuture.encodeRelay(CompletableFuture.java:368)
	at java.base/java.util.concurrent.CompletableFuture.completeRelay(CompletableFuture.java:377)
	at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1152)
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
	at java.base/java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:614)
	at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1163)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1311)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1840)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1806)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Caused by: org.xbill.DNS.lookup.NoSuchDomainException
	at org.xbill.DNS.lookup.LookupSession.buildResult(LookupSession.java:593)
	at org.xbill.DNS.lookup.LookupSession.lambda$lookupWithResolver$7(LookupSession.java:479)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
	... 9 more

The following code is able to reproduce the problem:

var dadr = DnsAddr.resolve("/dnsaddr/0.westend.paritytech.net/tcp/30333/p2p/12D3KooWKer94o1REDPtAhjtYR4SdLehnSrN8PEhBnZm5NBoCrMC");

DnsAddr is imported from org.peergos.protocol.dnsaddr.DnsAddr.

The peer we are trying to connect is:

/dns/0.westend.paritytech.net/tcp/30333/p2p/12D3KooWKer94o1REDPtAhjtYR4SdLehnSrN8PEhBnZm5NBoCrMC

We tried changing the format of the address but it didn’t work out:

/dnsaddr/0.westend.paritytech.net/p2p/12D3KooWKer94o1REDPtAhjtYR4SdLehnSrN8PEhBnZm5NBoCrMC

@ianopolous
Copy link
Member

You have not setup your DNS correctly.

dig +short _dnsaddr.0.westend.paritytech.net txt

See details here: https://github.com/libp2p/specs/blob/master/addressing/README.md#dnsaddr-links

But I think you don't want dnsaddr, but rather dns, dns4 or dns6

@bokoto000
Copy link
Author

I believe my DNS is set correctly.
The following code returns correctly an ipv4 address:

adr = InetAddress.getByName("0.westend.paritytech.net");
System.out.println(adr.getHostAddress());

I'm trying to populate Kademlia with peers using the findClosestPeers method of the Kademlia class. I get the following error for every address that has /dns/ in the beginning.

java.lang.IllegalArgumentException: Malformed multiaddr: '/dns/boot.stake.plus/tcp/37332
	at io.libp2p.core.multiformats.Multiaddr$Companion.parseString(Multiaddr.kt:195)

Populating Kademlia with peers using the bootstrapRoutingTable method of the Kademlia class also returns an error:

java.lang.IllegalArgumentException: Malformed multiaddr: '/dns/0.westend.paritytech.net/tcp/30333/ipfs/12D3KooWKer94o1REDPtAhjtYR4SdLehnSrN8PEhBnZm5NBoCrMC'
Caused by: java.lang.IllegalArgumentException: Unknown protocol name: 'dns'

Using dnsaddr or ip4 however works.

@ianopolous
Copy link
Member

ianopolous commented Mar 31, 2023

dnsaddr does not mean the domain points to an ip address. It is an ipfs specific txt record. See the link above.

@bokoto000
Copy link
Author

I see. However, I am not sure that this helps me with the issue.
When I bootstrap Kademlia with boot node:/dns/0.westend.paritytech.net/tcp/30333/p2p/12D3KooWKer94o1REDPtAhjtYR4SdLehnSrN8PEhBnZm5NBoCrMC I recieve this exception:

Malformed multiaddr: '/dns/0.westend.paritytech.net/tcp/30333/ipfs/12D3KooWKer94o1REDPtAhjtYR4SdLehnSrN8PEhBnZm5NBoCrMC

Can I use /dns/ addresses for boot nodes and dial them?

@ianopolous
Copy link
Member

That's an upstream bug in jvm-libp2p. You can work around it using dns4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants