Config for websocket star using rendezvous

Hi,

I’m trying to use js-ipfs programmatically, from Node.js, to share files between two nodes (processes) on the same machine only via Websockets using a rendezvous server running on localhost. In my case I also don’t want the nodes to listen on any ports and only make the connections via the rendezvous server to simulate the final set up where the nodes will be inaccessible from each other. I’ve read through the readme files but am confused as to the necessary config for the config.Bootstrap array setting as well as the Addresses.Swarm setting.

In the rendezvous tests it refers to an address of the form “/ip4/127.0.0.1/tcp/9090/ws/p2p-websocket-star/ipfs/”. Is the id here the peer id of the connecting node? So each process will supply a different ID generated using create() from the peer-id package?

Is this address what I put for the bootstrap node or Addresses.Swarm? If I run the rendezvous server on localhost what do I put for both settings?

Thanks for any help!
Simon

If you’re not planning to connect to js-ipfs nodes running in the browser, you don’t need the rendezvous server, you can simply directly connect the nodes over TCP with either setting the config.Bootstrap array to have the Multiaddr of the other node or do jsipfs swarm connect <multiaddr> (node.swarm.connect(<multiaddr>, cb) in code) where Multiaddr is the other node.

The addresses in Addresses.Swarm is which addresses you listen on locally, whereas bootstrap are addresses you connect to when you start the node.

Hi Victor,

Thanks for the input.

Ultimately I am looking to be able share files between PCs that are sitting on different firewalled networks (such as on different corporate networks) where the only knowledge of each other is the hashes of the files they wish to share. In these situations you can only really guarantee that each node can make outgoing connections to the Internet and only via HTTP(S) on standard ports (80/443). If I’m understanding how IPFS works correctly, then an architecture that I believe would work is that each node would connect to a specific websocker start rendezvous server running in AWS, and exposed on port 443…
At the moment I’m just trying to do this in a local network as it’s simpler for initial testing purposes. The docs for the rendezvous server don’t really talk about the necessary config and I’m struggling to figure it out. What you’re saying in terms of the addresses makes sense to me in terms of direct connections but I’m not sure how this translates to the websocket star rendezvous server approach.
Thanks,
Simon

I figured it out so am putting the solution here in case it’s useful for anyone else. Assuming you are running js-libp2p-websocket-star-rendezvous with the following command line on localhost:

rendezvous --port=9090 --host=127.0.0.1

You can then connect to it using the following code with JS IPFS:

const ipfsConfig = {
  repo: 'ipfs-' + Math.random(),
  config: {
    Addresses: {
      Swarm: ['/ip4/127.0.0.1/tcp/9090/ws/p2p-websocket-star']
    },
    "Bootstrap": [
    ],     
  }
};
const ipfs = new IPFS(ipfsConfig);

That is the address you specify for Addresses.swarm in the address of the rendezvous server. i.e. it not what you listen on but what others can connect to in order to communicate with you. No bootstrap addresses are required.

If you have two running instances of a NodeJS app with this code they will form a swarm and have each other as peers.