Hi, I’ve read the topic about Create own DHT bootstrap node, and I created a bootstrap node via NewDHT function
but, when I run the chat example,it always wait for “Searching for other peers…”
I run two chat peers , I think the first may be wait for search ,but why the second one also wait for search?
both of two chat peers connect my bootstrap node success, but they don’t seem to find each other…
I think I might be doing something wrong in creating the “bootstrap node”
how to create a bootstrap node correctly? PLEASE!!
below is my codes and logs
#bootstrap node code main.go#
package main
import (
"context"
"github.com/ipfs/go-log/v2"
"github.com/libp2p/go-libp2p"
"github.com/multiformats/go-multiaddr"
ds "github.com/ipfs/go-datastore"
dsync "github.com/ipfs/go-datastore/sync"
dht "github.com/libp2p/go-libp2p-kad-dht"
)
var logger = log.Logger("rendezvous")
func main() {
log.SetAllLoggers(log.LevelWarn)
log.SetLogLevel("rendezvous", "debug")
logger.Info("crate host")
host, err := libp2p.New(libp2p.ListenAddrs([]multiaddr.Multiaddr(nil)...))
if err != nil {
panic(err)
}
logger.Info("Host created. We are:", host.ID())
logger.Info(host.Addrs())
ctx := context.Background()
dstore := dsync.MutexWrap(ds.NewMapDatastore())
// kademliaDHT := dht.New(ctx, host)
kademliaDHT := dht.NewDHT(ctx, host, dstore)
if err != nil {
panic(err)
}
// Bootstrap the DHT. In the default configuration, this spawns a Background
// thread that will refresh the peer table every five minutes.
logger.Info("Bootstrapping the DHT")
if err = kademliaDHT.Bootstrap(ctx); err != nil {
panic(err)
}
// logger.Infof("%v%v", host.ID().Pretty(), host.Addrs())
select {}
}
#bootstrap run log#
> go run main.go
2022-04-14T15:35:50.232+0800 INFO rendezvous bootstrapnode/main.go:22 crate host
2022-04-14T15:35:50.340+0800 INFO rendezvous bootstrapnode/main.go:28 Host created. We are:QmboMwKV2AdRfdMqeYjy28d9RR9bv6Nt4kgWmXfMBAFn8o
2022-04-14T15:35:50.340+0800 INFO rendezvous bootstrapnode/main.go:29 [/ip4/192.168.3.88/tcp/60786 /ip4/127.0.0.1/tcp/60786 /ip6/::1/tcp/60789]
2022-04-14T15:35:50.341+0800 INFO rendezvous bootstrapnode/main.go:43 Bootstrapping the DHT
2022-04-14T15:35:50.342+0800 WARN dht/RtRefreshManager rtrefresh/rt_refresh_manager.go:136 failed when refreshing routing table2 errors occurred:
* failed to query for self, err=failed to find any peer in table
* failed to refresh cpl=0, err=failed to find any peer in table
2022-04-14T15:35:50.344+0800 WARN dht/RtRefreshManager rtrefresh/rt_refresh_manager.go:199 failed when refreshing routing table {"error": "2 errors occurred:\n\t* failed to query for self, err=failed to find any peer in table\n\t* failed to refresh cpl=0, err=failed to find any peer in table\n\n"}
2022-04-14T15:45:50.347+0800 WARN dht/RtRefreshManager rtrefresh/rt_refresh_manager.go:199 failed when refreshing routing table {"error": "2 errors occurred:\n\t* failed to query for self, err=failed to find any peer in table\n\t* failed to refresh cpl=0, err=failed to find any peer in table\n\n"}
#chat-with-rendezvous run log#
> go run . -peer=/ip4/127.0.0.1/tcp/60786/ipfs/QmboMwKV2AdRfdMqeYjy28d9RR9bv6Nt4kgWmXfMBAFn8o
2022-04-14T15:36:21.479+0800 INFO rendezvous chat-with-rendezvous/chat.go:104 Host created. We are:QmTGMQhxKqMp7AijWgCXZFDDqWPeLFxgmsEzjE1VFQcVH1
2022-04-14T15:36:21.480+0800 INFO rendezvous chat-with-rendezvous/chat.go:105 [/ip4/192.168.3.88/tcp/60795 /ip4/127.0.0.1/tcp/60795 /ip6/::1/tcp/60798]
2022-04-14T15:36:21.480+0800 DEBUG rendezvous chat-with-rendezvous/chat.go:123 Bootstrapping the DHT
2022-04-14T15:36:21.482+0800 WARN dht/RtRefreshManager rtrefresh/rt_refresh_manager.go:136 failed when refreshing routing table2 errors occurred:
* failed to query for self, err=failed to find any peer in table
* failed to refresh cpl=0, err=failed to find any peer in table
2022-04-14T15:36:21.484+0800 WARN dht/RtRefreshManager rtrefresh/rt_refresh_manager.go:199 failed when refreshing routing table {"error": "2 errors occurred:\n\t* failed to query for self, err=failed to find any peer in table\n\t* failed to refresh cpl=0, err=failed to find any peer in table\n\n"}
2022-04-14T15:36:21.496+0800 INFO rendezvous chat-with-rendezvous/chat.go:139 Connection established with bootstrap node:{QmboMwKV2AdRfdMqeYjy28d9RR9bv6Nt4kgWmXfMBAFn8o: [/ip4/127.0.0.1/tcp/60786]}
2022-04-14T15:36:21.496+0800 INFO rendezvous chat-with-rendezvous/chat.go:147 Announcing ourselves...
2022-04-14T15:36:21.496+0800 DEBUG rendezvous chat-with-rendezvous/chat.go:150 Successfully announced!
2022-04-14T15:36:21.496+0800 DEBUG rendezvous chat-with-rendezvous/chat.go:154 Searching for other peers...
2022-04-14T15:46:21.481+0800 WARN dht/RtRefreshManager rtrefresh/rt_refresh_manager.go:199 failed when refreshing routing table {"error": "2 errors occurred:\n\t* failed to query for self, err=failed to find any peer in table\n\t* failed to refresh cpl=0, err=failed to find any peer in table\n\n"}