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

**URL:** https://discuss.ipfs.tech/t/libp2p-io-websocket-fails-while-setting-up-node-in-a-browser-using-js-ipfs-and-pubsub/4549
**Category:** Help
**Tags:** js-ipfs
**Created:** [December 26, 2018, 5:04pm UTC](https://discuss.ipfs.tech/t/libp2p-io-websocket-fails-while-setting-up-node-in-a-browser-using-js-ipfs-and-pubsub/4549 "2018-12-26T17:04:11Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![adamskrodzki](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/adamskrodzki/32/2940_2.png) [@adamskrodzki](https://discuss.ipfs.tech/u/adamskrodzki)
#### Post date: [December 26, 2018, 5:04pm UTC](https://discuss.ipfs.tech/t/libp2p-io-websocket-fails-while-setting-up-node-in-a-browser-using-js-ipfs-and-pubsub/4549/1 "2018-12-26T17:04:11Z")

</div>

Hello,  
I’m building chat application using IPFS pubsub (with help of ipfs-pubsub-room)  
[https://chat.poadapps.com](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 😅

---

<div class="post-metadata">

### Author: ![gyuri](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/gyuri/32/1114_2.png) [@gyuri](https://discuss.ipfs.tech/u/gyuri)
#### Post date: [December 28, 2018, 7:08am UTC](https://discuss.ipfs.tech/t/libp2p-io-websocket-fails-while-setting-up-node-in-a-browser-using-js-ipfs-and-pubsub/4549/2 "2018-12-28T07:08:27Z")

</div>

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

> **[libp2p/js-libp2p-webrtc-star](https://github.com/libp2p/js-libp2p-webrtc-star)**
>
> libp2p WebRTC transport that includes a discovery mechanism provided by the signalling-star - libp2p/js-libp2p-webrtc-star

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

---

<div class="post-metadata">

### Author: ![adamskrodzki](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/adamskrodzki/32/2940_2.png) [@adamskrodzki](https://discuss.ipfs.tech/u/adamskrodzki)
#### Post date: [December 28, 2018, 8:16am UTC](https://discuss.ipfs.tech/t/libp2p-io-websocket-fails-while-setting-up-node-in-a-browser-using-js-ipfs-and-pubsub/4549/3 "2018-12-28T08:16:49Z")

</div>

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 😃

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

---

<div class="post-metadata">

### Author: ![gyuri](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/gyuri/32/1114_2.png) [@gyuri](https://discuss.ipfs.tech/u/gyuri)
#### Post date: [December 28, 2018, 8:53am UTC](https://discuss.ipfs.tech/t/libp2p-io-websocket-fails-while-setting-up-node-in-a-browser-using-js-ipfs-and-pubsub/4549/4 "2018-12-28T08:53:51Z")

</div>

Hi,

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

> <https://github.com/ipfs/js-ipfs/issues/1237#issuecomment-369186476>

---

<div class="post-metadata">

### Author: ![adamskrodzki](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/adamskrodzki/32/2940_2.png) [@adamskrodzki](https://discuss.ipfs.tech/u/adamskrodzki)
#### Post date: [December 28, 2018, 11:32am UTC](https://discuss.ipfs.tech/t/libp2p-io-websocket-fails-while-setting-up-node-in-a-browser-using-js-ipfs-and-pubsub/4549/5 "2018-12-28T11:32:28Z")

</div>

@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/](http://ec2-3-86-86-35.compute-1.amazonaws.com:9090/)
