Querying the DHT does not give any output

I added a file using IPFS add and then asked my friend (on a different network) to get the file. It did not work.

I tried querying the DHT using ipfs dht get <hash>, but still there was no response from the query (it times out).

I do not understand what we are missing here. When a ipfs daemon starts, where does it connect to? Is the default DHT locations hardcoded? Why is my request timing out?

Thanks

@AdwaitB Hello!

When a ipfs daemon starts, where does it connect to? Is the default DHT locations hardcoded?

Yes. This process is called “bootstrapping”. You can see the default nodes in the Bootstrap section of your ~/.ipfs/config file.

Two questions for you:

  1. How big is the file?
  2. Did your friend try getting the file immediately after you added it?

I ask because the process of providing a file to the network (that is, providing each of its blocks) takes longer than we want it to at the moment, and so the “solution” may be to wait a little longer.

Have you tried adding a small file to the network and checking if your friend can access it? Something like:

$ echo "something relatively unique between you and your friend" | ipfs add
added QmHash...

This should be available to your friend in, at most, a couple of minutes.

:smile:

Hello @michaelavila , thanks for the reply :slight_smile:.

The file is very small. I did the same thing you suggested. We were waiting for more than 20 mins. I also tried doing ipfs provide <hash>, but that takes a lot of time too.

Also, is it possible to host my own DHT server, without using ipfs-cluster for research purposes?

The file is very small. I did the same thing you suggested. We were waiting for more than 20 mins. I also tried doing ipfs provide <hash> , but that takes a lot of time too.

That’s too bad! Was your friend ever able to retrieve the content? Was the content available after running ipfs dht provide <hash>?

Also, is it possible to host my own DHT server, without using ipfs-cluster for research purposes?

Do you mean to use your own custom “DHT server”? Or to use a “DHT server” unique to your network? Really the DHT facilities come from the many nodes that make up your network. If your network is private and you’re not bootstrapping to the default nodes, then all of the DHT information in the network will be specific to only your network. If you want to go further and use your own custom implementation of the DHT, then you’d need to write some code. I’d start by looking at the current implementation:

In go:

In js:

Thanks,

No, we never were able to transfer the file.
ipfs dht provide <hash> eventually returned without any output, but we were unable to get the file.

I just want a “DHT server” private to my network.
So if I do ipfs bootstrap rm --all and then add only one node from my network to this bootstrap using ipfs bootstrap add /ip4/<nodeip>/tcp/4001/ipfs/<node_hash>, will I be able to run ipfs on my private network?

Thank you :slight_smile:

@AdwaitB an important thing I didn’t mention before was the swarm key, which you’ll need to generate and use. This looks like a good guide for what you’re trying to do:

https://mrh.io/ipfs-private-networks/

Thanks, I was able to run IPFS on a private network as given in the link :).
I still have the following questions.

  1. In this private network I built, how do I know which one is the DHT?
  2. Is there a way to manually specify one?
  3. Is the DHT an IPFS node, or will I have to host it manually?

@AdwaitB good to hear!

  1. If you’ve done nothing special, then the DHT functionality is distributed across the nodes in your network. Each node makes up part of the DHT.
  2. If you want a node dedicated to DHT work, then look at https://github.com/ipfs/dht-node
  3. Same as the answer to #1. Unless you specify otherwise, all of the nodes in your network are also “DHT nodes”.

Great, will have a look. The following question is not really related to this thread, but is a follow up.

I dig the IPFS code a bit and found out that all calls to the DHT go through this file. https://github.com/libp2p/go-libp2p-kad-dht/blob/master/routing.go. I am basically replacing the DHT with a custom algorithm to see performance difference. My code is in python which runs as a web service which I will call rather than calling the DHT.

The hack that I am trying is that rather than replacing the library, I shall just call my service from the following functions.

  1. Provide: when adding a file or a replica.
  2. FindProvidersAsync: when getting a file.

My questions are:

  1. Will this be sufficient for IPFS to work?
  2. Will there be some other DHT overheads that will still run? If yes, how do I nullify them?

Thanks :),