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

Commit 31a78e5

Browse files
committed
fix: disable WebRTC by default
1 parent 5940e27 commit 31a78e5

File tree

2 files changed

+45
-20
lines changed

2 files changed

+45
-20
lines changed

README.md

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ You can check the development status at the [Waffle Board](https://waffle.io/ipf
4242

4343
[![Throughput Graph](https://graphs.waffle.io/ipfs/js-ipfs/throughput.svg)](https://waffle.io/ipfs/js-ipfs/metrics/throughput)
4444

45-
**Important to note:** DHT and Relay are not finalized yet, you won't have resource discovery happening by default as you get in go-ipfs, we are working actively on these pieces, please follow:
45+
**Please read this:** DHT (automatic content discovery) and Circuit Relay (pierce through NATs and dial between any node in the network) are two fundamental pieces that are not finalized yet. There are multiple applications that can be built without these two services but nevertheless they are fundamental to get that magic IPFS experience. If you want to track progress or contribute, please follow:
46+
4647
- DHT: https://github.com/ipfs/js-ipfs/pull/856
47-
- Relay: https://github.com/ipfs/js-ipfs/pull/830
48+
- Relay: https://github.com/ipfs/js-ipfs/pull/1063
4849

4950
## Table of Contents
5051

@@ -54,10 +55,10 @@ You can check the development status at the [Waffle Board](https://waffle.io/ipf
5455
- [Through command line tool](#through-command-line-tool)
5556
- [Use in the browser](#use-in-the-browser)
5657
- [Usage](#usage)
57-
- [CLI](#cli)
58-
- [HTTP-API](#http-api)
59-
- [IPFS Core (use IPFS as a module in Node.js or in the Browser)](#ipfs-core-use-ipfs-as-a-module)
60-
- [Create a IPFS node instance](#create-a-ipfs-node-instance)
58+
- [IPFS CLI](#ipfs-cli)
59+
- [IPFS Daemon](#ipfs-daemon)
60+
- [IPFS Module (use IPFS as a module in Node.js or in the Browser)](#ipfs-module)
61+
- [How to create a IPFS node instance](#create-a-ipfs-node-instance)
6162
- [Tutorials and Examples](#tutorials-and-examples)
6263
- [API Docs](#api)
6364
- [Files](#files)
@@ -124,7 +125,7 @@ Inserting one of the above lines will make an `Ipfs` object available in the glo
124125

125126
## Usage
126127

127-
### CLI
128+
### IPFS CLI
128129

129130
The `jsipfs` CLI, available when `js-ipfs` is installed globally, follows(should, it is a WIP) the same interface defined by `go-ipfs`, you can always use the `help` command for help menus.
130131

@@ -150,11 +151,13 @@ Commands:
150151
- default Bootstrap is off, to enable it set `IPFS_BOOTSTRAP=1`
151152

152153

153-
### HTTP-API
154+
### IPFS Daemon
155+
156+
The IPFS Daemon exposes the API defined [`http-api-spec`](https://github.com/ipfs/http-api-spec). You can use any of the IPFS HTTP-API client libraries with it, such as: [js-ipfs-api](https://github.com/ipfs/js-ipfs-api).
154157

155-
The HTTP-API exposed by the js-ipfs daemon follows the [`http-api-spec`](https://github.com/ipfs/http-api-spec). You can use any of the IPFS HTTP-API client libraries with it, such as: [js-ipfs-api](https://github.com/ipfs/js-ipfs-api).
158+
### IPFS Module
156159

157-
### IPFS Core (use IPFS as a module)
160+
Use the IPFS Module as a dependency of a project to spawn in process instances of IPFS.
158161

159162
#### Create a IPFS node instance
160163

@@ -191,14 +194,14 @@ const node = new IPFS({
191194
// init: {
192195
// bits: 1024 // size of the RSA key generated
193196
// },
194-
start: true,
197+
start: true, // default
195198
// start: false,
196199
EXPERIMENTAL: { // enable experimental features
197200
pubsub: true,
198201
sharding: true, // enable dir sharding
199202
dht: true // enable KadDHT, currently not interopable with go-ipfs
200203
},
201-
config: { // overload the default IPFS node config
204+
config: { // overload the default IPFS node config, find defaults at https://github.com/ipfs/js-ipfs/tree/master/src/core/runtime
202205
Addresses: {
203206
Swarm: [
204207
'/ip4/127.0.0.1/tcp/1337'
@@ -322,6 +325,28 @@ A set of data types are exposed directly from the IPFS instance under `ipfs.type
322325

323326
## FAQ
324327

328+
#### How to enable WebRTC support for js-ipfs in the Browser
329+
330+
To add a WebRTC transport to your js-ipfs node, you must add a WebRTC multiaddr. To do that, simple override the config.Addresses.Swarm array which contains all the multiaddrs which the IPFS node will use. See below:
331+
332+
```JavaScript
333+
const node = new IPFS({
334+
config: {
335+
Addresses: {
336+
Swarm: [
337+
"/dns4/star-signal.cloud.ipfs.team/wss/p2p-webrtc-star"
338+
]
339+
}
340+
}
341+
})
342+
343+
node.on('ready', () => {
344+
// your instance with WebRTC is ready
345+
})
346+
```
347+
348+
**Important:** This transport usage is kind of unstable and several users have experienced crashes. Track development of a solution at https://github.com/ipfs/js-ipfs/issues/1088.
349+
325350
#### Is there WebRTC support for js-ipfs with Node.js?
326351

327352
Yes, however, bare in mind that there isn't a 100% stable solution to use WebRTC in Node.js, use it at your own risk. The most tested options are:
@@ -371,13 +396,7 @@ npm install electron-webrtc --global
371396

372397
Then, update your IPFS Daemon config to include the multiaddr for this new transport on the `Addresses.Swarm` array. Add: `"/dns4/star-signal.cloud.ipfs.team/wss/p2p-webrtc-star"`
373398

374-
#### I see some slowness when hopping between tabs Chrome with IPFS nodes, is there a reason why?
375-
376-
Yes, unfortunately, due to [Chrome aggressive resource throttling policy](https://github.com/ipfs/js-ipfs/issues/611), it cuts freezes the execution of any background tab, turning an IPFS node that was running on that webpage into a vegetable state.
377-
378-
A way to mitigate this in Chrome, is to run your IPFS node inside a Service Worker, so that the IPFS instance runs in a background process. You can learn how to install an IPFS node as a service worker in here the repo [ipfs-service-worker](https://github.com/ipfs/ipfs-service-worker)
379-
380-
#### How can I configure an IPFS node to use a custom `signaling server`?
399+
#### How can I configure an IPFS node to use a custom `signaling endpoint` for my WebRTC transport?
381400

382401
You'll need to execute a compatible `signaling server` ([libp2p-webrtc-star](https://github.com/libp2p/js-libp2p-webrtc-star) works) and include the correct configuration param for your IPFS node:
383402

@@ -398,6 +417,13 @@ const node = new IPFS({
398417

399418
The code above assumes you are running a local `signaling server` on port `9090`. Provide the correct values accordingly.
400419

420+
#### I see some slowness when hopping between tabs Chrome with IPFS nodes, is there a reason why?
421+
422+
Yes, unfortunately, due to [Chrome aggressive resource throttling policy](https://github.com/ipfs/js-ipfs/issues/611), it cuts freezes the execution of any background tab, turning an IPFS node that was running on that webpage into a vegetable state.
423+
424+
A way to mitigate this in Chrome, is to run your IPFS node inside a Service Worker, so that the IPFS instance runs in a background process. You can learn how to install an IPFS node as a service worker in here the repo [ipfs-service-worker](https://github.com/ipfs/ipfs-service-worker)
425+
426+
401427
## Packages
402428

403429
| Package | Version | Deps | DevDeps | Build |

src/core/runtime/config-browser.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"Addresses": {
33
"Swarm": [
4-
"/dns4/star-signal.cloud.ipfs.team/wss/p2p-webrtc-star"
54
],
65
"API": "",
76
"Gateway": ""

0 commit comments

Comments
 (0)