I’ve app that use Helia node(js-ipfs) before. My goal is to provide browser-to-browser connection between 2 Helia.
So I want use Kubo node with public IP(DNS also) as middlemanto obtain peerId of another Helia node, and then use STUN/TURN public servers to establish direct connection between two browser nodes.
Also I want to use circuit relay first if it’s possible for same purpose.
Unfortunately I’m unable to find some documents related to that. Is that described somewhere?
Please help me how to enable webRTC and circuit-relay on Kubo, that will be compatible with Helia.
Those 2 lines I’ve been added to my transport section in Kubo config:
- Is it correct? What else Is necessary?
- What about /webrtc-direct is it still used?
- What requiriments is to use Kubo as relayer, should it work out of the box for Helia if WSS connections is possible?
This is a part of libp2p config used for Helia.
urls: ['TURN:freestun.net:3479', 'TURNS:freestun.net:5350'],
I found your post because I had the same question. I have doubts that this can be accomplished with Kubo. (I am not sure at all)
So far it was never possible to use Kubo as a WebRTC-star or relay for browser nodes. Kubo doesn’t speak WebRTC at all. You always needed a dedicated (and centralized) WebRTC-star service node. As far as I remember, you could use it as Websocket relay but this had to be done with wss (e.g. ssl via nginx proxy) instead of ws (in case it is not running on the local machine).I I thought, I had this working last year, but for some reason either something changed with Kubo or Helia or something else was breaking inbetween. So probably Helia isn’t doing the WebRTC-star anymore as js-ipfs was doing it before. (only an assumption)
With the latest version of Kubo from yesterday v0.24.0 WebRTC-direct should be possible in case the WebRTC peer is not behind firewall or router as they write. (a mobile phone might work, but they are working on it). I guess kubo has released some tests here if you want to dig into it.
Release v0.24.0 · ipfs/kubo · GitHub.
Your first question, your config cannot be correct, because WebRTC is not possible.
- traditionally WebRTC and WebRTC-direct can be used only between browser peers and with Helia running on NodeJS.
As far as I understand, you still need a special relay service in order to accomplish what you want to do:
- https://github.com/libp2p/js-libp2p-examples/tree/main/examples/js-libp2p-example-browser-pubsub. (unfortunately firefox doesn’t seem to work - see and run the tests, I couldn’t find the reason)
- this is an example where you can use circuit-relay instead of ws wait for helia1 to listen on WebRTC and use multiaddr-matcher to find correct address by achingbrain · Pull Request #2 · haydenyoung/helia-browser · GitHub
So as you can see, you touched the current front line of Helia/Kubo developments and those are the questions probably all are working on at the moment. As soon it is working, this will be amazing.
You can setup a dedicated public relay service as in the above examples until its working with Kubo. This might be the thing I am going to do now. I’ll keep you updated as in case or as soon as I have better information.
I have to correct myself! It is possible! Sorry for the confusion.
I just made it work with Webtransport and WebRTC-direct.
Btw. Don’t install a Kubo on a local machine, it might not work! (not 100% confirmed but it seems like this). Please install Kubo on a public machine!
Here is my description:
I installed a brand new Kubo and ran the following little test app of mine!
- git clone --depth=1 --branch v0.24.0 GitHub - ipfs/kubo: An IPFS implementation in Go
- 4004:4004 to ports section of docker-compose.yml (webrtc-direct should run on udp port 4004)
- started kubo via
cd kubo && docker compose up -d
- enabled WebRTC in config by executing:
docker compose exec ipfs ipfs config Swarm.Transports.Network.WebRTCDirect --json true
"/ip4/0.0.0.0/udp/4004/webrtc-direct" to ipfs config (Addresses.Swarm) by
docker compose exec ipfs ipfs config Addresses.Swarm '["/ip4/0.0.0.0/tcp/4001","/ip6/::/tcp/4001","/ip4/0.0.0.0/udp/4001/quic-v1","/ip4/0.0.0.0/udp/4001/quic-v1/webtransport","/ip4/0.0.0.0/udp/4004/webrtc-direct","/ip6/::/udp/4001/quic-v1","/ip6/::/udp/4004/webrtc-direct","/ip6/::/udp/4001/quic-v1/webtransport"]' --json
- enabled relay and AutoNAT (not sure if thats necessary - but maybe useful for others in the network)
docker compose exec ipfs ipfs config --bool Swarm.RelayService.Enabled true
docker compose exec ipfs ipfs config --bool Swarm.EnableAutoNATService true
docker compose exec ipfs ipfs config --bool Swarm.RelayClient.Enabled true
- restarted Kubo with
docker compose down && docker compose up -d
- checked if Kubo now sees my webrtc-direct multi address by executing
docker compose exec ipfs ipfs id (can take some moments). Kubo even lists the public IP of my router. (not sure if thats okey?!)
- anyhow, I took my 127.0.0.1 webrtc-direct MultiAddress /ip4/127.0.0.1/udp/4004/webrtc-direct/certhash/xyzblablabla/p2p/12DblablablaNodeId
- I put it into “Dial MultiAddr” textbox of my https://simpleheliaorbitsvelte.vercel.app/#/libp2p/pubsub libp2p pubsub testing app
- You get all the MultiAddreses of the public Kubo in the first dropdown after some moments. (follow instructions on my playground)
Let me know if that helps. The crucial part is libp2p config for Helia anyways.