peerjs icon indicating copy to clipboard operation
peerjs copied to clipboard

Websocket connection now failing without any apparent reasons

Open marcoippolito opened this issue 5 years ago • 7 comments

I left the web-app friday night with no problems. Today, I'm experiencing something I do not understand, since during weekend I didn't touch anything at all:

"peerjs.min.js?a0bc:52 WebSocket connection to 'wss://0.peerjs.com/peerjs?key=peerjs&
id=bemz4x7v4ua00000&token=7k5a8y9cso' failed: Connection closed before receiving a 
handshake response
o.start @ peerjs.min.js?a0bc:52
i._initialize @ peerjs.min.js?a0bc:66
eval @ peerjs.min.js?a0bc:66"

I tried many times, and only twice I got the connection working fine (and without doing anything special)... ERR_CONNECTION_REFUSED-01

What kind of causes could lead the web socket connection to fail? Looking forward to your kind help. Marco

marcoippolito avatar May 25 '20 14:05 marcoippolito

See https://github.com/peers/peerjs/issues/671#issuecomment-633265565. The public signaling server seems to by unstable at the moment. Consider setting up your own signaling-server

Florrr avatar May 26 '20 05:05 Florrr

@Florrr Hi Florian! I'm trying to understand how to setup a signaling-server, but I have some doubt about it: in my Peerjs.vue file I created a new server using PeerServer object:

My app is running behind an nginx proxy server.

data: () => ({
    peerServer: PeerServer({
        port: 9000,
        path: '/ggc',
    }),

But when I run npm run server I get this error:

image

If I run the server as follows:

$ peerjs --port 9000 --key peerjs --path /myapp
Started PeerServer on ::, port: 9000, path: /myapp (v. 0.5.3)

Going in the browser to http://127.0.0.1:9000/myapp

image

In Peerjs.vue I substitute the "old" Peer creation with:

  created() {
    //this.myPeer = new Peer()
    this.myPeer = new Peer(1, {
      host: 'localhost',
      port: 9000,
      path: '/myapp'
    })

    this.myPeer.on('open', () => {
      console.log('this.myPeer.id: ' + this.myPeer.id + ' this.myPeer.key: ' + this.myPeer.key);
    })

Still get this error: "WebSocket connection to 'wss://localhost:9000/myapp/peerjs?key=peerjs&id=1&token=xueb5dzxk4l' failed: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR "

image

How to solve the problem? Looking forward to your kind help. Marco

marcoippolito avatar May 26 '20 07:05 marcoippolito

@Florrr I opened a new issue here about the signaling server setup: https://github.com/peers/peerjs-server/issues/193

marcoippolito avatar May 26 '20 08:05 marcoippolito

I just spent three hours today diagnosing a similar problem. The SSL protocal sslv3 was being used. The node server had never been updated. sslv3 is deprecated. Need to make sure the node server, nginx, apache are using the latest tls 1.2 Or your browser will throw an error. In firefox...

about:config

security.tls

natesire avatar May 28 '20 19:05 natesire

I setup a signaling server on heroku to test it.

peerjs.min.js is changing the protocol to ws (non secure)

var peer = new Peer('natusdrew2', { host: "wss://hidden-beach-54481.herokuapp.com/myapp", key: "natuskey2" } )

https://javascript.info/websocket

Says to use wss://

I think peerjs.min.js just needs to fix the parsing of the url. That's why we are receiving the SSL error. It's downgrading it to a ws:// connection.

ws

natesire avatar May 29 '20 02:05 natesire

Interesting @natusdrew .

So... @Florrr what kind of solutions can we use? At the moment I'm stuck here: https://github.com/peers/peerjs-server/issues/193

marcoippolito avatar May 29 '20 07:05 marcoippolito

@natusdrew you probably need to specify the "host"-value without the wss:// prefix. this is added automatically (wss or ws depending on the secure-property). If you want to connect using wss use: var peer = new Peer('natusdrew2', { host: "hidden-beach-54481.herokuapp.com/myapp", key: "natuskey2", secure: true } ) for connecting using ws: var peer = new Peer('natusdrew2', { host: "hidden-beach-54481.herokuapp.com/myapp", key: "natuskey2", secure: false } )

Florrr avatar Jun 01 '20 20:06 Florrr