I added to /etc/hosts 127.0.0.1 my domain name :
(base) marco@pc01:~$ tail /etc/hosts
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.0.1 peer1.acme.com
127.0.0.1 peer1.budget.com
127.0.0.1 orderer.acme.com
127.0.0.1 postgresql
127.0.0.1 explorer
127.0.0.1 vagrant
127.0.0.1 ggc.world
I modified the websocket’s part of /etc/nginx/conf.d/default.conf as:
upstream websocket {
server ggc.world:13579;
}
server {
listen 8443 ssl;
server_name ggc.world;
ssl_certificate /etc/letsencrypt/live/ggc.world-0002/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/ggc.world-0002/privkey.pem; # managed by Certbot
ssl_trusted_certificate /etc/letsencrypt/live/ggc.world/chain.pem;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location /p2p {
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade "Websocket";
proxy_set_header Connection "Upgrade";
proxy_set_header Host ggc.world;
}
}
This is the vue page :
<template>
<div class="hello">
</div>
</template>
<script>
// https://github.com/libp2p/js-libp2p/tree/master/examples/libp2p-in-the-browser
import Libp2p from 'libp2p'
import Websockets from 'libp2p-websockets'
import WebRTCStar from 'libp2p-webrtc-star'
import { NOISE } from 'libp2p-noise'
import Secio from 'libp2p-secio'
import Mplex from 'libp2p-mplex'
import Boostrap from 'libp2p-bootstrap'
export default {
name: 'Libp2p',
data () {
return {
// our libp2p node
libp2p: null,
status: "",
output: ""
}
},
created() {
(async () =>{
// Create our libp2p node
this.libp2p = await Libp2p.create({
addresses: {
listen: ['/dns4/ggc.world/tcp/8443/wss/p2p-webrtc-star/p2p
/QmT.....9']
},
modules: {
transport: [Websockets, WebRTCStar],
connEncryption: [NOISE, Secio],
streamMuxer: [Mplex],
peerDiscovery: [Boostrap]
},
config: {
peerDiscovery: {
bootstrap: {
enabled: true,
list: [
'/dns4/ams-1.bootstrap.libp2p.io/tcp/443/wss/p2p
/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd',
'/dns4/lon-1.bootstrap.libp2p.io/tcp/443/wss/p2p
/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3',
'/dns4/sfo-3.bootstrap.libp2p.io/tcp/443/wss/p2p
/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM',
'/dns4/sgp-1.bootstrap.libp2p.io/tcp/443/wss/p2p
/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu',
'/dns4/nyc-1.bootstrap.libp2p.io/tcp/443/wss/p2p
/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm',
'/dns4/nyc-2.bootstrap.libp2p.io/tcp/443/wss/p2p
/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64'
]
}
}
}
// Listen for new peers
this.libp2p.on('peer:discovery', (peerId) => {
console.log(`Found peer ${peerId.toB58String()}`)
})
// Listen for new connections to peers
this.libp2p.connectionManager.on('peer:connect', (connection) => {
console.log(`Connected to ${connection.remotePeer.toB58String()}`)
})
// Listen for peers disconnecting
this.libp2p.connectionManager.on('peer:disconnect', (connection) => {
console.log(`Disconnected from ${connection.remotePeer.toB58String()}`)
})
await this.libp2p.start();
})()
},
}
</script>
I started the ipfs daemon:
(base) marco@pc01:~$ ipfs daemon
Initializing daemon...
go-ipfs version: 0.5.0
Repo version: 9
System version: amd64/linux
Golang version: go1.13.10
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/172.17.0.1/tcp/4001
Swarm listening on /ip4/192.168.1.7/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/172.17.0.1/tcp/4001
Swarm announcing /ip4/192.168.1.7/tcp/4001
Swarm announcing /ip4/37.116.208.13/tcp/45067
Swarm announcing /ip6/::1/tcp/4001
API server listening on /ip4/127.0.0.1/tcp/5001
WebUI: http://127.0.0.1:5001/webui
Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/9090
Daemon is ready
I started the signaling server:
(base) marco@pc01:~$ star-signal --port=13579 --host=127.0.0.1
Listening on: http://127.0.0.1:13579
I started the webapp:
DONE Compiled successfully in 6358ms 10:52:38 AM
App running at:
- Local: http://localhost:8080
- Network: http://ggc.world/
Note that the development build is not optimized.
To create a production build, run npm run build.
I get this new error:
“WebSocket connection to ‘wss://ggc.world:8443/socket.io/?EIO=3&transport=websocket’ failed: Error during WebSocket handshake: Unexpected response code: 404
Uncaught (in promise) Error: Transport (WebRTCStar) could not listen on any available address”