Libp2p.io WebSocket fails while setting up node in a browser using js-ipfs and pubsub

Hello,
I’m building chat application using IPFS pubsub (with help of ipfs-pubsub-room)
https://chat.poadapps.com

and I have problems with setting up nodes

I’m getting error (You can see it in console log of website):

bundle.js:37906 WebSocket connection to 'wss://ws-star.discovery.libp2p.io/socket.io/?EIO=3&transport=websocket' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
WS.doOpen @ bundle.js:37906
.............

bundle.js:36738 Uncaught Error: websocket error
    at WS.Transport.onError (bundle.js:36738)
    at WebSocket.ws.onerror (bundle.js:37944)

I believe it is related to following code

        const node = new IPFS({
            repo: repoName,
            EXPERIMENTAL: {
                pubsub: true,
                dht: false /*TODO jak załadować options.modules.dht*/ ,
                sharding: false
            },
            config: {
                Addresses: {
                    Swarm: [
                        '/dns4/ws-star.discovery.libp2p.io/tcp/443/wss/p2p-websocket-star'
                    ]
                }
            }
        });

I’ve tried to change Address to:
“/dns4/star-signal.cloud.ipfs.team/wss/p2p-webrtc-star”

but it does not solve the problem.

If I do not specify adresses nodes do not see each other

Also I could swear several days ago this code worked :sweat_smile:

The signal server is down. You need to run your own.

Just install it with npm and it gives you a global command star-signal


Unfortunately there are no instructions on there on how to setup a secure wss signal server.

1 Like

Hi,

thank You for answer

On github I can find:

A libp2p-webrtc-star address, using the signalling server we provide, looks like:

/dns4/star-signal.cloud.ipfs.team/wss/p2p-webrtc-star/ipfs/<your-peer-id>

How i can get my <your-peer-id>

without initializing Ipfs object (I need this address on initialisation phase)

Also,

How to make such website trully decentralized? If my web still requires to connect to specific server I run, whole thing goes down if discovery goes down

can list of all available discovery servers be fetched from somewhere?

For example current IPFS hash of nodes list stored on Ethereum blockchain :smiley:

I’m still learning and it is all a kind of magic.

Hi,

you need to run your own app’s signal server along with your web app.

@gyuri

thanks for help,

however I’m facing new issue now:

It does not throw error after bootstraping in following way:

const node = new IPFS({
repo: repoName,
EXPERIMENTAL: {
  pubsub: true,
  dht: false /*TODO jak załadować options.modules.dht*/ ,
  sharding: false
},
config: {
  Addresses: {

    Swarm: [
      "/dns4/ec2-3-86-86-35.compute-1.amazonaws.com/tcp/9090/ws/p2p-websocket-star/ipfs/" + from.id,
    ]
  }
}

});

But now

node.swarm.peers().then(console.log)

is empty

and

node.bootstrap.list().then(console.log)

returns one element

["/dns4/3.86.86.35/wss/p2p-webrtc-star/ipfs/QmYiXvGjRAsviVo5g56evAbSVpvJQG9kEmqLZu4d5Zx4di"]

Is theree something wrong with signalling-server ? Firewall?

My signalling-server is running

http://ec2-3-86-86-35.compute-1.amazonaws.com:9090/