-
Notifications
You must be signed in to change notification settings - Fork 502
Description
I am aware of #2437, this is not the same issue as I'm trying to dial a node by its multiaddress.
- Version:
"@libp2p/webrtc": "^5.2.24",
"@multiformats/multiaddr": "^13.0.1",
"libp2p": "^2.10.0"
- Platform:
Darwin 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:16 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6000 arm64
- Subsystem:
WebRTC direct
Severity:
High or Medium depending on who you ask (someone that wants to connect nodes using webrtc-direct, things are not working)
Description:
I'm trying to connect a browser node to both a go-node and a nodejs node by dialing the multiaddresses using webrtc-direct as transport. In an attempt to figure out if this only happens with browsers I tried to connect the nodejs node to the go-node and the same error happened.
Steps to reproduce the error:
// go node
import (
libwebrtc "github.com/libp2p/go-libp2p/p2p/transport/webrtc"
golibp2p "github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
)
opts := []golibp2p.Option{
golibp2p.ListenAddrStrings("/ip4/0.0.0.0/udp/4444/webrtc-direct"),
golibp2p.Identity(priv),
golibp2p.DisableRelay(),
golibp2p.Transport(libwebrtc.New),
}
n, err := golibp2p.New(opts...)
remoteInfo := peer.AddrInfo{ID: n.ID(), Addrs: n.Network().ListenAddresses()}
remoteAddrs, _ := peer.AddrInfoToP2pAddrs(&remoteInfo)
fmt.Println("p2p addr: ", remoteAddrs[0]) // something in line with: /ip4/0.0.0.0/udp/4444/webrtc-direct/certhash/<cert-hash>/p2p/<peer-id>
import { createLibp2p } from 'libp2p'
import { webRTCDirect } from '@libp2p/webrtc'
import { multiaddr } from '@multiformats/multiaddr'
const listener = await createLibp2p({
addresses: { listen: [ '/ip4/0.0.0.0/udp/4455/webrtc-direct' ] },
transports: [ webRTCDirect() ]
})
await listener.start()
listener.dial(multiaddr("/ip4/127.0.0.1/udp/4444/webrtc-direct/certhash/<cert-hash>/p2p/<peer-id>)) // do notice the change from 0.0.0.0 -> 127.0.0.1
Both the browser and nodejs nodes throw the same error when using dial
(and dialProtocol
): TypeError: multiaddrs[0].getPeerId is not a function
Example code to dial taken from examples all around libp2p docs.