A little confused about IPFS

First, I am slowly working, actually researching how I might be able to distribute a WebRTC broadcast using IPFS, So, there appears to be two implimentation of IPFS: go-IPFS and js-IPFS.
Confusion one: What is the difference between the two? Which one is most stable? Which should I consider when working with WebRTC?

Confusion two: Do I create an IPFS server on the internet and install IPFS there? I see reference to install it locally on my PC, but not sure how to use it?

I did read some of the IPFS documentation, but there is no clarity about where to install IPFS and how to use.

Ideally I’d like to see a tutorial on building a multi-user website being distributed by IPFS. I realize there is a lot more needed to stream Webrtc using IPFS. I’m just trying to develop an overall concept in my mind with how to administer something like this. Would IPFS and the Website be on the same server?

So, in a nutshell, my idea is this: A live streamer would access the website and start his steam. Subscribed users would be notified and they could view his live stream which is being distributed via IPFS.

Hope I make sense to you.

Thanks in advance.

Ray

Confusion 1: go-ipfs is written in go, which is a language compiling to native code (hence faster than javascript) specialized in concurrent programming, so it is the reference implementation of IPFS and the most stable one. But if you’re making a browser application that uses WebRTC, js-ipfs should be your choice, firstly because browsers can only interpret javascript (and not go) and because WebRTC is a javascript API.

Confusion 2: You don’t have to run your IPFS instance on a publicly available server on the internet, in fact you can install it on your home computer, as you would with any bittorrent client, and it would work just fine. IPFS handles all the annoying stuff like NAT-traversal by itself so you don’t have to deal with it.

If you want a web application on the browser that utilizes IPFS and that works without the need for users to download anything, there are 2 options:

  • write your app on Node.js, install IPFS via npm i ipfs, and use a javascript bundler like webpack or browserify to run it on the browser,
  • write your app directly for the browser (in a HTML file or in an imported JS file) and import the IPFS script version like so:

<script src="https://cdnjs.cloudflare.com/ajax/libs/ipfs/0.39.0/index.min.js"></script>

Caveat: the javascript version is slower and less stable than the go version. So if you don’t care that your users have to install some software beforehand in order to use you application, then go-ipfs is the way to go. You can install go-ipfs by following these instructions, and if you want to have a better user interface, you can also install Web UI and IPFS Companion.

So to answer your question “Would IPFS and the Website be on the same server?”:

  • Firstly, the website won’t be hosted on any webserver, it will be distributed among peers who are willing to seed it. Keep in mind that IPFS is a peer-to-peer protocol. Unless you only want to use IPFS for the browser-to-browser communication during the livestream and you don’t care if your static files are stored on a centralized server, so you can host your website on a regular HTTP webserver.
  • Secondly, the IPFS instances will always be run on the users’ computers. If it is js-ipfs, the user will download the code and start the IPFS instance each time he goes to your website (unless it is cached) and imports the javascript of the <script> tag containing js-ipfs. If it is go-ipfs, the users of your application will have go-ipfs installed and running beforehand on their PC, and they will connect your app to their local IPFS gateway.

Here are two interesting tutorials on js-ipfs :

I think the PubSub demo is particularly interesting for your project, because you could create a PubSub room for each of your streaming sessions. But I don’t know if js-ipfs is suitable for streaming video using the WebRTC API. If you don’t mind a little bit of centralization in your application (mainly for storing your static files (HTML/CSS/JS) and for the WebRTC signalling process), I suggest you to rather take a look on PeerJS instead of IPFS.

1 Like