Peerjs: Unable to connect

Created on 4 Jul 2020  ·  18Comments  ·  Source: peers/peerjs

Getting error https://0.peerjs.com/peerjs/id?ts=15938580580230.27749202685512375 net::ERR_CONNECTION_TIMED_OUT since the latest update.

Most helpful comment

Fix cloud server please, I'm having a final project at the moment. I must finished it before tomorrow.

All 18 comments

Fix cloud server please, I'm having a final project at the moment. I must finished it before tomorrow.

Looks like this is a server issue.

I'm having the same issue. It worked yesterday in the evening around 8pm EST, but since today when I tried running my code again, timeouts on 0.peerjs.com. I even tried to spin up a server on gitpod, but I'm having the same issues there. I'm not sure if this is a peerjs-server issue or not, I was getting the following results when running peerjs-1.2 and peerjs-1.3.

OS: Windows 10
Browsers: Chrome Version 83.0.4103.116 and Firefox 78.0.1

Attempt with custom peerId
peerjs.min.js:52 WebSocket connection to 'wss://0.peerjs.com/peerjs?key=peerjs&id=c-pU_AYDp&token=a6g0yo6t7ma' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT

Attempt with server autogenerated id
peerjs.min.js:64 GET https://0.peerjs.com/peerjs/id?ts=15938872126070.5702383625139162 net::ERR_CONNECTION_TIMED_OUT

I have been trying to learn how to use PeerJS and the example at https://peerjs.com/examples.html does not work. I think there is an issue with the PeerJS cloud server.

I found out that deploy your own peerjs-server solve all your problem

Where did you deploy your server? A cloud service or self hosted?

Where did you deploy your server? A cloud service or self hosted?

You can go this link https://github.com/peers/peerjs-server, click on 'Open on Gitpod' and start your own new peer-server. With those config
new Peer([id], { host: [your-host-name], port: 443, secure: true })
Until now my server can connect but send message got some error. Maybe you can try and help me solve it.

Where did you deploy your server? A cloud service or self hosted?

You can go this link https://github.com/peers/peerjs-server, click on 'Open on Gitpod' and start your own new peer-server. With those config
new Peer([id], { host: [your-host-name], port: 443, secure: true })
Until now my server can connect but send message got some error. Maybe you can try and help me solve it.

I've created a new server but I'm getting this error.
Error: Could not get an ID from the server. If you passed in a 'path' to your self-hosted PeerServer, you'll also need to pass in that same path when creating a new Peer

How do I fix this?

Adimarthur8: You'll need to manually specify an I'd if your peerjs server isn't setup to automatically generate them.

And I tried gitpod, but it wouldn't connect for me. I eventually got heroku working. I was missing the secure: true. That was the key for me.

Seems to work on gitpod although a bit unintuitive ...

peer = new Peer(
  {
    host: 'yourPersonalGitPodKey.gitpod.io',
    port: '443',
    path: '/',
    secure: true
  });

Note path (/), port (443), secure (to enable https rather than http).

Also:
You can get URL from the gitpod "preview" window - you will see port number there (443 in my case).
You can see see logs in gitpod terminal.
You can also start server in terminal -> npm start

Seems to work on gitpod although a bit unintuitive ...

peer = new Peer(
  {
    host: 'yourPersonalGitPodKey.gitpod.io',
    port: '443',
    path: '/',
    secure: true
  });

Note path (/), port (443), secure (to enable https rather than http).

Also:
You can get URL from the gitpod "preview" window - you will see port number there (443 in my case).
You can see see logs in gitpod terminal.
You can also start server in terminal -> npm start

Hi, I've done what you did and now the client can initialize a new Peer with an ID.
However, when I try to connect two Peers together, the Peer client who is trying to connect trigger an error like that : ERROR PeerJS: Error: Could not connect to peer 377b4bb0-3101-4af0-9203-f85210

I've tried many time with differents browsers but always the same result, it's impossible to connect two Peers together.

Also, the Peer client who is waiting for a connection don't trigger any messages or errors in the console (I have activated debug : 3 in the Peer parameters)

Adimarthur8: You'll need to manually specify an I'd if your peerjs server isn't setup to automatically generate them.

And I tried gitpod, but it wouldn't connect for me. I eventually got heroku working. I was missing the secure: true. That was the key for me.

Deploying a private server on Heroku made it work!

I am thinking that if you received ID, signalling/brokering is working.

Not sure if related to your issue but for chrome browsers (may others as well) one needs to manually set:

peer.on('connection', function(data){
...
data.open = true;
})

I alway got this error every time send a message, how can I fix it?
image

I think i know what the problem is.. (i'm new to this so feel free to correct me)

I opened the link to the js file.. and found that the url to the sourceMappingfile at the end was /peerjs.min.js.map
so I tried to visit https://unpkg.com/[email protected]/dist/peerjs.min.js.map and apparently that link does not exist..
I checked for the latest peerjs file sourcemap using this link and found that it was 1.2.0 (i think this is the latest as of now?)
So then i checked the url: https://unpkg.com/[email protected]/dist/peerjs.min.js.map (notice the version)
and it worked ..
So either the either the sourceMapping url in the original file must be changed or the url that it points to must be available..

Simplest fix i think would be to use the https://unpkg.com/[email protected]/dist/peerjs.min.js (the old version )(i haven't used it though)

Another way to fix this would be (but not sure i'ts okay to do this..)

  1. download the [peerjs.min.js] (https://unpkg.com/[email protected]/dist/peerjs.min.js)
  2. download the peerjs.min.js.map (the old version)
  3. include these downloaded file in your html
    Note that the two files must be in the same folder else you have to edit the peerjs.min.js file and edit the //#sourceMappingURL=/peerjs.min.js.map to //# sourceMappingURL=<path to the map file>

Here is a temporary "solution" that can be used individually for the meantime, but it does not fix the net issue with the site or examples.

Hi, I've done what you did and now the client can initialize a new Peer with an ID.
However, when I try to connect two Peers together, the Peer client who is trying to connect trigger an error like that : ERROR PeerJS: Error: Could not connect to peer 377b4bb0-3101-4af0-9203-f85210

I've tried many time with differents browsers but always the same result, it's impossible to connect two Peers together.

Also, the Peer client who is waiting for a connection don't trigger any messages or errors in the console (I have activated debug : 3 in the Peer parameters)

same problem

the map file was fixed in 1.3.1

Using this minimal example:

<head>
    <script src="https://unpkg.com/[email protected]/dist/peerjs.min.js"></script>
    <script>
        const peer = new Peer();
    </script>
</head>
<body>
    Hi!
</body>

There's an error
peerjs.min.js:64 GET https://0.peerjs.com/peerjs/id?ts=15952851209220.3286421092199203 net::ERR_CONNECTION_REFUSED
Windows 10, Chrome/84.0.4147.89

Are servers down, when will they be up?

This error is gone when using server deployed on gitpod

Edit: server is now working again

Using this minimal example:

<head>
    <script src="https://unpkg.com/[email protected]/dist/peerjs.min.js"></script>
    <script>
        const peer = new Peer();
    </script>
</head>
<body>
    Hi!
</body>

There's an error
peerjs.min.js:64 GET https://0.peerjs.com/peerjs/id?ts=15952851209220.3286421092199203 net::ERR_CONNECTION_REFUSED
Windows 10, Chrome/84.0.4147.89

Are servers down, when will they be up?

This error is gone when using server deployed on gitpod

Edit: server is now working again

I had this problem on localhost, but it turns out that I had not started the peerjs server. After starting the server, the problem was fixed.

Was this page helpful?
0 / 5 - 0 ratings