Can't seem to get browser js-ipfs functioning over the net using webrtc-star or circuit-relay

Working on writing a tutorial to get people jump-started on js-ipfs, however I’ve hit a snag … I have a few questions:

  1. What are the pros/cons of webrtc-star and circuit-relay?
  2. Can they be used in conjunction?
  3. How do I achieve connectivity given my scenarios below? (What am I doing wrong?)

Setup:

  • Browser A: Home connection
  • Browser B: VPN connection
  • Star: star.thedisco.zone
  • RelayNode: ipfs.thedisco.zone

Testing here: http://portal.thedisco.zone/testing/chat.html

The script used to load IPFS was retrieved from here.

Scenario 1:

Browser config:

await Ipfs.create({
	repo: 'ok' + Math.random(),
	config: {
		Addresses: {
			Swarm: [ '/dns4/star.thedisco.zone/tcp/9090/wss/p2p-webrtc-star', '/dns6/star.thedisco.zone/tcp/9090/wss/p2p-webrtc-star', "/ip4/0.0.0.0/tcp/4002", "/ip4/127.0.0.1/tcp/4003/ws" ]
		}
}});

Result:

If multiple browser sessions are launched on home connection nodes discover eachother fine over star however remote peers are not discovered (Browser A cannot discover or connect to Browser B).

Additionally, Browser B and Browser A are 100% connected to the star node. The nodes however will not connect to eachother.

Scenario 2:

Browser config:

await Ipfs.create({
	repo: 'ok' + Math.random(),
	relay: {
		enabled: true,
		hop: {
			enabled: true
		}
	},
	config: {
		Bootstrap: [ '/dns6/ipfs.thedisco.zone/tcp/4430/wss/p2p/12D3KooWChhhfGdB9GJy1GbhghAAKCUR99oCymMEVS4eUcEy67nt', '/dns4/ipfs.thedisco.zone/tcp/4430/wss/p2p/12D3KooWChhhfGdB9GJy1GbhghAAKCUR99oCymMEVS4eUcEy67nt' ]
}});

go-ipfs config: { "API": { "HTTPHeaders": {} }, "Addresses": { "API": "/ip4/1 - Pastebin.com

Result:

Multiple home connection nodes fail to discover eachother, likewise Browser A never connects to Browser B, connection is not relayed.

The RelayNode shows up in the swarm list, but that’s about it. There are no addresses listed on Browser A or Browser B under ipfs.id().

Additionally when trying to connect between nodes (via await ipfs.swarm.connect("/ipfs/12D3KooWChhhfGdB9GJy1GbhghAAKCUR99oCymMEVS4eUcEy67nt/p2p-circuit/ipfs/<DEST PEERID>");, there is no error, or any output at all for that matter (not even “undefined”). They don’t show up in the ipfs.swarm.peers(); list.

Edit:

When trying to connect using the relay I get Uncaught Error: no protocol with name: "'p2p'". Must have a valid family name: "{ip4, ip6, dns4, dns6}"..

If I try await ipfs.swarm.connect("/dns6/ipfs.thedisco.zone/tcp/4430/wss/p2p/12D3KooWChhhfGdB9GJy1GbhghAAKCUR99oCymMEVS4eUcEy67nt/p2p-circuit/dns6/<PEERID>"); instead, it doesn’t return an error, but it also doesn’t add to the peer list.

Progress :tada:!

So I got one successful connection going for a fleeting moment. I connected with:

await ipfs.swarm.connect("/dns6/ipfs.thedisco.zone/tcp/4430/p2p/12D3KooWChhhfGdB9GJy1GbhghAAKCUR99oCymMEVS4eUcEy67nt/p2p-circuit/p2p/<PEERID>");

However often I get errors when trying to do this:

Error: HOP request failed with code 260

Error: The operation was aborted

After that one successful connection I haven’t succeeded since, but I’ve been given hope.

I should also mention I changed my config slightly:

relay: {
		enabled: true,
		hop: {
			enabled: false,
			active: true
		}
},

I’m under the impression enabled on hop advertises I am a relay, but I’m trying to use one. I hope this understanding is correct.

I tried changing my config to disable both enabled and active on the hop config … not sure it did anything though.

relay: {
		enabled: true,
		hop: {
			enabled: false,
			active: false
		}
},

I realised upon init, Browser A and Browser B can happily connect. However in a minute or 2 they disconnect, and I cannot reconnect them.

Edit:

Some new questions come to mind, as I’m able to establish an initial connection…

  1. Why do I lose connection after some time to peers I connect to through the relay?
  2. Why can I not reconnect to these peers after the disconnection? I’m still peered with the relay itself.
  3. Any way I can announce my p2p-circuit multiaddress? It doesn’t display in ipfs.id(), and I need to manually connect.
  1. webrtc-star allows browser-browser communication, circuit-relay is useful when this isn’t possible
  2. Yes.
  3. For star, connecting to local peers is expected, for relay, this:
await ipfs.swarm.connect("/dns6/ipfs.thedisco.zone/tcp/4430/p2p/12D3KooWChhhfGdB9GJy1GbhghAAKCUR99oCymMEVS4eUcEy67nt/p2p-circuit/p2p/<TARGET_PEERID>");
  1. js-ipfs doesn’t implement a keepalive, you have to do this yourself: Peers disconnect every 10 minutes
  2. Not sure
  3. For now I’m going to put an additional software on my node that looks for js-ipfs peers and announces their p2p-circuit multiaddress over a pubsub channel