Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

peers don't connect automatically through circuit, but they do through websocket-star rendezvous server #1309

Closed
fazo96 opened this issue Apr 13, 2018 · 6 comments
Labels
P2 Medium: Good to have, but can wait until someone steps up status/ready Ready to be worked

Comments

@fazo96
Copy link

fazo96 commented Apr 13, 2018

  • Version: master
  • Platform: Arch Linux and also latest version of Chrome
  • Subsystem: libp2p-circuit I think? The problem is with circuit relay

Type: Question

Severity: Medium

Description:

In my application, instances subscribe to a specific pubsub topic and I monitor the peers to see how many of my application's nodes I am connected to.

We are currently using rendezvous servers and websocket-star to connect browser nodes and it works great, however I wanted to try to replace this with connecting to a couple of relay-hop capable js-ipfs nodes via wss and then having browser tabs connect to each other with circuit.

The problem is that with rendezvous servers, the browser peers automatically connect to each other just because they are using the same rendezvous server. I expected the same with circuit, but instead I have to manually dial /p2p-circuit/ipfs/<peerid> to get the peers to connect.

In short, circuit works but it doesn't automatically connect peers which can't connect directly, while if I use rendezvous it does. This makes rendezvous better in this case even though I understand that circuit is supposed to replace the rendezvous server mechanism, at least for websocket connections.

My Question is, is this expected behavior or missing functionality? How would I recreate the same behavior as websocket-star using circuit and have the peers connect automatically?

Steps to reproduce the error:

  • have two peers only listen through a wss rendezvous server
  • have them subscribe to the same random pubsub topic
  • monitor peers subscribed to the topic to make sure the two nodes see each other
  • the nodes automatically see each other at startup, because they connect through the rendezvous server
  • do the same thing but instead of using a rendezvous server, have the nodes turn on relay and connect to the same "server" node using wss. The "server" node needs to be relay-hop capable
  • note how even after a couple of minutes after starting the three nodes up, the two peers don't see each other in the pubsub topic, but if you dial from one to the other using /p2p-circuit/ipfs/<peerid> they connect immediatly and see each other
@daviddias
Copy link
Member

Thanks for bringing this up, @fazo96, I understand where the confusion comes from.

websocket-star offers transport + peer discovery and that is why you see them connecting right away. libp2p-circuit is just dialing. The path moving forward is to enable the DHT (wip) and disable websocket-star so that peers discover each other using the DHT giving you that same experience with libp2p-circuit only.

@fazo96
Copy link
Author

fazo96 commented May 2, 2018

I see, so the DHT is the missing piece. Thanks for clearing this up.

Maybe we can keep this open until #856 is done and the peers can discover each other like with websocket-star.

@dryajov
Copy link
Member

dryajov commented May 3, 2018

In addition to what @diasdavid mentioned, there is also the upcoming rendezvous spec libp2p/specs#44, and respective implementations, that will replace our existing add-hoc rendezvous implementations (*-star transports currently). This new implementation will allow peer discovery in addition to the dht, but also namespace based registration/querying of peers, that should enable a more complete service discovery mechanism.

@daviddias daviddias added status/ready Ready to be worked P2 Medium: Good to have, but can wait until someone steps up labels Jun 4, 2018
@gitGksgk
Copy link

gitGksgk commented Oct 23, 2018

In summary, currently browser nodes can discover each other automatically with rendezvous server, but with p2p-circuits they just dialing thus can't discover each other automatically.

But why is it that my js-ipfs daemon node can't discover nodes in the same net ? using js-ipfs 0.32.3, default configuration, added nothing but a private net protector

          libp2p.modules.connProtector = protector
          libp2p.modules.connProtector.protect = protector.protect

corresponding config setting in .jsipfs (default setting):

  "Discovery": {
    "MDNS": {
      "Enabled": true,
      "Interval": 10
    },
    "webRTCStar": {
      "Enabled": true
    }
  },

ps. my go-ipfs node can discover other machines. it's discovery config part is

 "Discovery": {
    "MDNS": {
      "Enabled": true,
      "Interval": 10
    }
  },

when using node src\cli\bin.js swarm connect to a known node in another machine it shows Circuit not enabled and all transports failed to dial peer

@gitGksgk
Copy link

got it. it's because js-ipfs doesn't enable circuits by default. adding

  "relay": {
    "enabled": true,
    "hop": {
      "enabled": true
    }
  }

to config in .jsipfs fixed it

@alanshaw alanshaw closed this as completed Nov 1, 2018
@fazo96
Copy link
Author

fazo96 commented Nov 6, 2018

@alanshaw I saw you closed the issue, is the original problem fixed now?

I mean, is there a way to make peers using the same IPFS JS app discover and connect automatically (directly or through relays with circuit) without using a centralised websocket-star redenzvous server?

geolffreym referenced this issue Jul 1, 2020
Per #2779 , this PR adds the public webrtc servers to the browser example.

This allows users to run easily the example, but also provides information for how users should use a signaling server for production.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P2 Medium: Good to have, but can wait until someone steps up status/ready Ready to be worked
Projects
None yet
Development

No branches or pull requests

5 participants