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

Getting an IPFS instance to connect to a swarm doesn't work (or docs incomplete) #1534

Closed
patientplatypus opened this issue Sep 1, 2018 · 3 comments
Labels
kind/support A question or request for support

Comments

@patientplatypus
Copy link

I've been looking at this for a while, and as far as I can tell this is a bug and not bad code. Essentially, outside of using p2p-websocket-star or similar there does not appear to be a working way of setting up a personal swarm. Either that or everything that I've read in the documentation here and elsewhere is incomplete.

I have a detailed write up on stack overflow (https://stackoverflow.com/questions/52130383/ipfs-swarm-address-malformed) which I will not reproduce here. But in essence the point where I've gotten stuck is that after using https://github.com/libp2p/js-libp2p-websocket-star (as mentioned in the docs to use) to set up a websocket server and pointing the IPFS command to that swarm

ie:

const ipfs = new IPFS({
  repo: "ipfs/sharedFolder",
  EXPERIMENTAL: {
    pubsub: true
  },
  config: {
    Addresses: {
      Swarm: [
        '/ip4/127.0.0.1/tcp/9090/ws/p2p-websocket-star'
      ]
    }
  }
})

I just get errors, and I can't broadcast a message between two open tabs.

Again, I've been on stack overflow and IRC quite a bit trying to resolve this and have come to the conclusion that it appears that I'm doing everything correctly at the API level, so there is something most likely going wrong under the hood.

Thanks!

@patientplatypus
Copy link
Author

Addendum....Ok I got it now - thought I should post an update in case anyone stumbles onto this.

What you need to do is make sure you have your swarm address in you ~/.ipfs/config file pointing to 4001 for a websocket connection like this:

"Addresses": {
    "API": "/ip4/127.0.0.1/tcp/5001",
    "Announce": [],
    "Gateway": "/ip4/127.0.0.1/tcp/8080",
    "NoAnnounce": [],
    "Swarm": [
      "/ip4/0.0.0.0/tcp/4001/ws", //<----this
      "/ip4/0.0.0.0/tcp/4001",
      "/ip6/::/tcp/4001",
      "/ip4/192.168.1.18/tcp/5001"
    ]
  },

Next you have to make sure that the rendezvous server that p2p-websocket-star provides is online and running (see here: https://github.com/libp2p/js-libp2p-websocket-star-rendezvous). One caveat ~ currently there is a bug (maybe, maybe not?) in rendezvous that is causing potentially too many connections in socket.io resulting in this output:

patientplatypus:~:11:55:24$rendezvous
Listening on: http://0.0.0.0:9090
(node:96815) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 disconnect listeners added. Use emitter.setMaxListeners() to increase limit

There have been issues with this commented here: libp2p/js-libp2p-websocket-star-rendezvous#12, but I don't think they have been resolved yet (see here: libp2p/js-libp2p-websocket-star#58). If anyone has any ideas or another library that is more stable as a websocket transmitter please let me know!

Thanks.

@alanshaw
Copy link
Member

@patientplatypus can this be closed?

FYI there's documentation on this in the README - are we missing something?

@alanshaw alanshaw added kind/support A question or request for support status/ready Ready to be worked labels Sep 10, 2018
@patientplatypus
Copy link
Author

You can close this issue thanks - there is no known solution yet for the memory leak, but I believe that is another problem.

@ghost ghost removed the status/ready Ready to be worked label Sep 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/support A question or request for support
Projects
None yet
Development

No branches or pull requests

2 participants