-
Notifications
You must be signed in to change notification settings - Fork 7
Connection to found peers does not work #149
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
Comments
Is this issue fixed? |
I am also using pubsub-peer-discovery and since some times it doesn't work anymore. Out of my perspective the discovered peerId doesn't have any multiaddrs. Peer 12D3xxxxxxYuAd discovered: 12D3KxxxxJTE I am using two different browsers which connect to a local relay via wss. |
I changed the following two things in my libp2p config and then at least I could fix the issue with the empty multiaddrs!
PubSubPeerDiscovery still does not connect to the discovered peers automatically, so I had to do that manually in such a way in my browser code (here Svelte Code). They question is raised, if we should to add an "autodial" flag to the PubSubPeerDiscovery Module and dial from there. $libp2p?.addEventListener('peer:discovery', async (evt) => {
const peer = evt.detail
console.log(`Peer ${$libp2p?.peerId.toString()} discovered: ${peer.id.toString()}`)
console.log('peer.multiaddrs', peer)
const connections = $libp2p?.getConnections(peer.id)
if (!connections || connections.length === 0) {
console.log(`Dialing new peer: ${peer.id.toString()}`)
// Try each multiaddr until one succeeds
let connected = false
for (const addr of peer.multiaddrs) {
try {
console.log('dialing', addr.toString())
await $libp2p?.dial(addr)
console.log('Successfully dialed:', addr.toString())
connected = true
break // Exit the loop once successfully connected
} catch (error) {
console.warn(`Failed to dial ${addr.toString()}:`, error.message)
}
}
if (!connected) {
console.error(`Failed to connect to peer ${peer.id.toString()} on all addresses`)
}
} else {
console.log(`Already connected to peer: ${peer.id.toString()}`)
}
}) That is my libp2p config export const Libp2pOptions = {
addresses: {
listen: [
'/p2p-circuit',
"/webrtc",
"/webtransport",
"/wss", "/ws",
]
},
transports: [
webTransport(),
webSockets({filter: filters.all}),
webRTC({
rtcConfiguration: {
iceServers:[{
urls: [
'stun:stun.l.google.com:19302',
'stun:global.stun.twilio.com:3478'
]
}]
}
}),
webRTCDirect(),
circuitRelayTransport({ discoverRelays: 1 })
],
connectionEncrypters: [noise()],
streamMuxers: [
yamux(),
],
connectionGater: {
denyDialMultiaddr: () => {
return false
}
},
peerDiscovery: [
bootstrap(bootstrapConfig),
pubsubPeerDiscovery({
interval: 10000,
topics: pubSubPeerDiscoveryTopics, // defaults to ['_peer-discovery._p2p._pubsub']
listenOnly: false,
})
],
services: {
identify: identify(),
identifyPush: identifyPush(),
ping: ping(),
autoNAT: autoNAT(),
dcutr: dcutr(),
pubsub: gossipsub({ allowPublishToZeroTopicPeers: true, canRelayMessage: true })
}
} |
Uh oh!
There was an error while loading. Please reload this page.
I have updated all libraries to the latest versions at the moment.
Node configuration.
relay
Before the update, the search worked.
Peer search event is triggered now.
Request is made.
But connection is not made.
logs
And this log is repeated.
In the new version of the libp2p library, the autoDial module was removed. Apparently, this is why the module stopped working.
Do I have any errors in the configuration or do I need to change something in the library?
The text was updated successfully, but these errors were encountered: