Hello! I’m using libp2p with Go and have a problem with testing on the same machine. It worked before but I made changes to the new peer connection code and don’t recall what I changed. I’m sure I’m doing something trivially wrong / stupid. The problem is that when I connect the second instance, it cannot dial to the other instance:
discovered new local peer 12D3KooWAFTWvnqmGQghYvpVvHub85G5CAPwVTcrMBPPnBk124hr
discovered new local peer 12D3KooWAFTWvnqmGQghYvpVvHub85G5CAPwVTcrMBPPnBk124hr
error connecting to local peer 12D3KooWAFTWvnqmGQghYvpVvHub85G5CAPwVTcrMBPPnBk124hr: failed to dial 12D3KooWAFTWvnqmGQghYvpVvHub85G5CAPwVTcrMBPPnBk124hr: no good addresses
error connecting to local peer 12D3KooWAFTWvnqmGQghYvpVvHub85G5CAPwVTcrMBPPnBk124hr: failed to dial 12D3KooWAFTWvnqmGQghYvpVvHub85G5CAPwVTcrMBPPnBk124hr: no good addresses
The first instance starts without any errors. I’m using the following code to create each new peer, where a different privkey
is generated for each instance with crypto.GenerateKeyPair()
:
// create the host
n.host, err = libp2p.New(n.ctx,
libp2p.ListenAddrStrings(
"/ip4/0.0.0.0/tcp/4001", // regular tcp connections over IPv4
"/ip4/0.0.0.0/udp/4001/quic", // a UDP endpoint for the QUIC transport
"/ip6/::/tcp/4001", // tcp over IPv6
"/ip4/127.0.0.1/tcp/0", // same machine loopback interface
),
libp2p.Identity(privkey),
libp2p.NATPortMap(),
// support TLS connections
libp2p.Security(libp2ptls.ID, libp2ptls.New),
// support secio connections
libp2p.Security(secio.ID, secio.New),
// support QUIC
libp2p.Transport(libp2pquic.NewTransport),
libp2p.DefaultTransports,
libp2p.ConnectionManager(connmgr.NewConnManager(
100, // Lowwater
400, // HighWater,
time.Minute, // GracePeriod
)),
// routing DHT
libp2p.Routing(func(h host.Host) (routing.PeerRouting, error) {
n.dht, err = dht.New(n.ctx, h)
return n.dht, err
}),
libp2p.EnableAutoRelay())