peerjs-server icon indicating copy to clipboard operation
peerjs-server copied to clipboard

Peerjs server deployed on heroku is not working

Open Chhinna opened this issue 4 years ago • 15 comments

I used the deploy on Heroku button from this link to deploy a peerjs server. To connect to this server I used

const peer = new Peer(host: 'focusmonk-beta.herokuapp.com', port:9000, path:'/')

But this is not working, am I missing something ?

Chhinna avatar Jul 27 '20 08:07 Chhinna

That's because the default password is wrong. Trying to find a fix

veerareddyvishal144 avatar Aug 02 '20 10:08 veerareddyvishal144

Any update on this, its saying connected but not receiving connection on two peers ? @vishalveerareddy @Chhinna

RamyaAshika avatar Oct 03 '20 11:10 RamyaAshika

you need to use the port 443 I had the same issue. But I encountered another one :(. Due to security issues I cannot send my getUserMedia stream over the peer js connection.

ElmouradiAmine avatar Nov 19 '20 12:11 ElmouradiAmine

I'm facing a similar issue. Is there any fix for this or not? The request for https://<server-name>.herokuapp.com:9000/peer-server/peerjs/id?ts=16312062773910.47823913209901503 is failing due to CORS request did not succeed error. How to fix this?

siddharthmagadum16 avatar Sep 09 '21 17:09 siddharthmagadum16

I'm facing a similar issue. Is there any fix for this or not? The request for https://<server-name>.herokuapp.com:9000/peer-server/peerjs/id?ts=16312062773910.47823913209901503 is failing due to CORS request did not succeed error. How to fix this?

As Amine said above, you need to set 433 port in your url when you use https connection, or 80 port for http. This is default TCP ports.

blyzniuk avatar Sep 26 '21 19:09 blyzniuk

I'm facing a similar issue. Is there any fix for this or not? The request for https://<server-name>.herokuapp.com:9000/peer-server/peerjs/id?ts=16312062773910.47823913209901503 is failing due to CORS request did not succeed error. How to fix this?

As Amine said above, you need to set 433 port in your url when you use https connection, or 80 port for http. This is default TCP ports.

Yeah, we need to use port 443, otherwise, it won't work. I ended up using the 0.peerjs.com peer cloud server which runs on port 443 instead of creating my own peer server.

siddharthmagadum16 avatar Sep 26 '21 19:09 siddharthmagadum16

I am getting this error, GET https://https//realtime-notepad-voice.herokuapp.com/:433/peerjs/peerjs/id?ts=16351849542150.5264754979506276 net::ERR_NAME_NOT_RESOLVED.

I have set the port to 433 still i am getting this error. It works fine on local host, but when i deploy on heroku i get this error. I also found this in the headers. Referrer Policy: strict-origin-when-cross-origin

zaidm124 avatar Oct 25 '21 18:10 zaidm124

@zaidm124 I have solved this issue using peer cloud instead of my own peer server. peer cloud server: https://0.peerjs.com. I think you actually can't set reserved ports, and Heroku assigns random ports. If you still want to make your own peer server, you need to use Nginx to use reserved ports as far as I have heard while I encountered this issue.

siddharthmagadum16 avatar Oct 25 '21 19:10 siddharthmagadum16

I am getting this error, GET https://https//realtime-notepad-voice.herokuapp.com/:433/peerjs/peerjs/id?ts=16351849542150.5264754979506276 net::ERR_NAME_NOT_RESOLVED.

I have set the port to 433 still i am getting this error. It works fine on local host, but when i deploy on heroku i get this error. I also found this in the headers. Referrer Policy: strict-origin-when-cross-origin

Have you seen your request url? It's completely broken There should be https://realtime-notepad-voice.herokuapp.com:433/peerjs..., but you have https://https//realtime-notepad-voice.herokuapp.com/:433/peerjs/

blyzniuk avatar Oct 25 '21 19:10 blyzniuk

I am getting this error, GET https://https//realtime-notepad-voice.herokuapp.com/:433/peerjs/peerjs/id?ts=16351849542150.5264754979506276 net::ERR_NAME_NOT_RESOLVED. I have set the port to 433 still i am getting this error. It works fine on local host, but when i deploy on heroku i get this error. I also found this in the headers. Referrer Policy: strict-origin-when-cross-origin

Have you seen your request url? It's completely broken There should be https://realtime-notepad-voice.herokuapp.com:433/peerjs..., but you have https://https//realtime-notepad-voice.herokuapp.com/:433/peerjs/

but i have copied that url from the console, i dont think i can correct that

zaidm124 avatar Oct 25 '21 19:10 zaidm124

I am getting this error, GET https://https//realtime-notepad-voice.herokuapp.com/:433/peerjs/peerjs/id?ts=16351849542150.5264754979506276 net::ERR_NAME_NOT_RESOLVED.

I have set the port to 433 still i am getting this error. It works fine on local host, but when i deploy on heroku i get this error. I also found this in the headers. Referrer Policy: strict-origin-when-cross-origin

Here is the frontend code for using peer cloud server.

import Peer from "peerjs";
const myPeer = new Peer(undefined, {
    key: "peerjs",
    debug: 2,
    secure: process.env.REACT_APP_ENV === "PRODUCTION" ? true : false, // secure : false for http connection
  });

you can refer more in the docs https://peerjs.com/docs.html#start

siddharthmagadum16 avatar Oct 25 '21 19:10 siddharthmagadum16

@zaidm124 Can you share how do you connect to peerjs on the client side?

My configuration for custom peerjs server on heroku:

server (part of my express app):

const peerServer = ExpressPeerServer(httpServer)
expressApp.use('/peerjs', peerServer)

client:

new Peer(userInfo.uid, {
    path: '/peerjs',
    host: '/',
    port: '433', // 433 for https, 80 for http
  })

blyzniuk avatar Oct 25 '21 19:10 blyzniuk

@zaidm124 Can you share how do you connect to peerjs on the client side?

My configuration for custom peerjs server on heroku:

server (part of my express app):

const peerServer = ExpressPeerServer(httpServer)
expressApp.use('/peerjs', peerServer)

client:

new Peer(userInfo.uid, {
    path: '/peerjs',
    host: '/',
    port: '433', // 433 for https, 80 for http
  })

let peer = new Peer(undefined, { path: '/peerjs', secure: true, host: 'https://realtime-notepad-voice.herokuapp.com/', port: '433', });

This is what i did

zaidm124 avatar Oct 25 '21 19:10 zaidm124

This may be helpful : #9 for someone

siddharthmagadum16 avatar Oct 25 '21 19:10 siddharthmagadum16

Thank you so much everyone, the problem is solved for me now. Peer cloud server worked. Thank you again @blyzniuk @siddharthmagadum16

I am getting this error, GET https://https//realtime-notepad-voice.herokuapp.com/:433/peerjs/peerjs/id?ts=16351849542150.5264754979506276 net::ERR_NAME_NOT_RESOLVED. I have set the port to 433 still i am getting this error. It works fine on local host, but when i deploy on heroku i get this error. I also found this in the headers. Referrer Policy: strict-origin-when-cross-origin

Here is the frontend code for using peer cloud server.

import Peer from "peerjs";
const myPeer = new Peer(undefined, {
    key: "peerjs",
    debug: 2,
    secure: process.env.REACT_APP_ENV === "PRODUCTION" ? true : false, // secure : false for http connection
  });

you can refer more in the docs https://peerjs.com/docs.html#start

This worked for me, thank you so much for helping me out.

zaidm124 avatar Oct 25 '21 19:10 zaidm124