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

**URL:** https://discuss.ipfs.tech/t/cant-seem-to-get-browser-js-ipfs-functioning-over-the-net-using-webrtc-star-or-circuit-relay/10953
**Category:** Help
**Tags:** js-ipfs
**Created:** [April 16, 2021, 8:41pm UTC](https://discuss.ipfs.tech/t/cant-seem-to-get-browser-js-ipfs-functioning-over-the-net-using-webrtc-star-or-circuit-relay/10953 "2021-04-16T20:41:13Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Discordian](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/discordian/32/4692_2.png) [@Discordian](https://discuss.ipfs.tech/u/Discordian)
#### Post date: [April 16, 2021, 8:41pm UTC](https://discuss.ipfs.tech/t/cant-seem-to-get-browser-js-ipfs-functioning-over-the-net-using-webrtc-star-or-circuit-relay/10953/1 "2021-04-16T20:41:13Z")

</div>

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](http://portal.thedisco.zone/testing/chat.html)

The script used to load IPFS was retrieved from [here](https://github.com/ipfs/js-ipfs/tree/master/examples/browser-script-tag).

## Scenario 1:

Browser config:

```js
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:

```js
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: [https://pastebin.com/dMMqgNjZ](https://pastebin.com/dMMqgNjZ)

### 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.

---

<div class="post-metadata">

### Author: ![Discordian](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/discordian/32/4692_2.png) [@Discordian](https://discuss.ipfs.tech/u/Discordian)
#### Post date: [April 16, 2021, 9:54pm UTC](https://discuss.ipfs.tech/t/cant-seem-to-get-browser-js-ipfs-functioning-over-the-net-using-webrtc-star-or-circuit-relay/10953/2 "2021-04-16T21:54:49Z")

</div>

Progress 🎉!

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

```auto
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:

```auto
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.

---

<div class="post-metadata">

### Author: ![Discordian](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/discordian/32/4692_2.png) [@Discordian](https://discuss.ipfs.tech/u/Discordian)
#### Post date: [April 16, 2021, 10:11pm UTC](https://discuss.ipfs.tech/t/cant-seem-to-get-browser-js-ipfs-functioning-over-the-net-using-webrtc-star-or-circuit-relay/10953/3 "2021-04-16T22:11:23Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

### Author: ![Discordian](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/discordian/32/4692_2.png) [@Discordian](https://discuss.ipfs.tech/u/Discordian)
#### Post date: [April 17, 2021, 6:13am UTC](https://discuss.ipfs.tech/t/cant-seem-to-get-browser-js-ipfs-functioning-over-the-net-using-webrtc-star-or-circuit-relay/10953/4 "2021-04-17T06:13:56Z")

</div>

> [@Discordian](#):
>
> 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?)
> 4. Why do I lose connection after some time to peers I connect to through the relay?
> 5. Why can I not reconnect to these peers after the disconnection? I’m still peered with the relay itself.
> 6. 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:

```js
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](https://discuss.ipfs.tech/t/peers-disconnect-every-10-minutes/8105)
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
