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

Commit 0b64c3e

Browse files
authored
chore: update example with public webrtc servers (#3126)
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.
1 parent a96e3bc commit 0b64c3e

File tree

2 files changed

+29
-22
lines changed

2 files changed

+29
-22
lines changed

examples/exchange-files-in-browser/README.md

+27-21
Original file line numberDiff line numberDiff line change
@@ -135,25 +135,7 @@ Daemon is ready
135135

136136
Check the `/ws` in line 5, that means it is listening. Cool.
137137

138-
### 3. Start a `libp2p-webrtc-star` signaling server
139-
140-
This server allows the two browser nodes to talk to each other by doing the initial handshake and network introductions.
141-
142-
First install the `libp2p-webrtc-star` module globally:
143-
144-
```sh
145-
> npm install -g libp2p-webrtc-star
146-
```
147-
148-
This will give you the `webrtc-star` command. Use this to start a signaling server:
149-
150-
```sh
151-
> webrtc-star
152-
```
153-
154-
By default it will listen to all incoming connections on port 13579. Override this with the `--host` and/or `--port` options.
155-
156-
### 4. Start the app
138+
### 3. Start the app
157139

158140
Make sure you're in `js-ipfs/examples/exchange-files-in-browser`.
159141

@@ -177,7 +159,7 @@ Hit CTRL-C to stop the server
177159

178160
Now go to http://127.0.0.1:12345 in a modern browser and you're on!
179161

180-
### 5. Dial to a node using WebSockets (your desktop ones)
162+
### 4. Dial to a node using WebSockets (your desktop ones)
181163

182164
Make sure you have a daemon running. If you don't, run:
183165

@@ -209,7 +191,7 @@ Check that you got connected:
209191
210192
[js-libp2p-crypto#105]: https://github.com/libp2p/js-libp2p-crypto/issues/105
211193

212-
### 6. Transfer files between all of your nodes!
194+
### 5. Transfer files between all of your nodes!
213195

214196
Now you can add files through the CLI with:
215197

@@ -235,3 +217,27 @@ http://127.0.0.1:12345/#file-exchange
235217
Now every file that you upload in one tab will appear in the other! You can even open a new tab in that workspace and it will sync the files that were added before!
236218

237219
![](img/pubsub.png)
220+
221+
## Going to production?
222+
223+
This example uses public webrtc-star servers. These servers should be used for experimenting and demos, they **MUST** not be used in production as there is no guarantee on availability.
224+
225+
### Use your own `libp2p-webrtc-star` signaling server
226+
227+
This server allows the two browser nodes to talk to each other by doing the initial handshake and network introductions.
228+
229+
First install the `libp2p-webrtc-star` module globally:
230+
231+
```sh
232+
> npm install -g libp2p-webrtc-star
233+
```
234+
235+
This will give you the `webrtc-star` command. Use this to start a signaling server:
236+
237+
```sh
238+
> webrtc-star
239+
```
240+
241+
By default it will listen to all incoming connections on port 13579. Override this with the `--host` and/or `--port` options. That is, the following multiaddr: `/ip4/127.0.0.1/tcp/13579/wss/p2p-webrtc-star`.
242+
243+
You should add your signaling server in the IPFS config swarm addresses, so that you listen for new connections through it.

examples/exchange-files-in-browser/public/app.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ async function start () {
5252
Addresses: {
5353
Swarm: [
5454
// This is a public webrtc-star server
55-
// '/dns4/star-signal.cloud.ipfs.team/tcp/443/wss/p2p-webrtc-star'
55+
'/dns4/wrtc-star1.par.dwebops.pub/tcp/443/wss/p2p-webrtc-star',
56+
'/dns4/wrtc-star2.sjc.dwebops.pub/tcp/443/wss/p2p-webrtc-star',
5657
'/ip4/127.0.0.1/tcp/13579/wss/p2p-webrtc-star'
5758
]
5859
},

0 commit comments

Comments
 (0)