Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy PeerJS server on Heroku

I have a problem with PeerJS server. I used "Deploy to Heroku" button from here: https://github.com/peers/peerjs-server

I have no idea how can I connect with deployed cloud. I can't find clear documentatnion about PeerJS Server.

I don't know what is the host, port, and path for my app.

var peer = new Peer('someid', {host: 'localhost', port: 9000, path: '/myapp'});

Please advice.

like image 369
Damian Avatar asked Jan 03 '18 20:01

Damian


People also ask

Is PeerJS part of WebRTC?

But there is some good news; PeerJS is a WebRTC framework that abstracts away all of the ice and signalling logic so that you can focus on the functionality of your application. There are two parts to PeerJS, the client-side framework and the server.

What is PeerJS in node JS?

PeerJS simplifies WebRTC peer-to-peer data, video, and audio calls. PeerJS wraps the browser's WebRTC implementation to provide a complete, configurable, and easy-to-use peer-to-peer connection API. Equipped with nothing but an ID, a peer can create a P2P data or media stream connection to a remote peer.


2 Answers

This how it worked for me:

var peer = new Peer('someid', {
                secure: true, 
                host: 'your-app-name.herokuapp.com', 
                port: 443,
    });
like image 169
xims Avatar answered Sep 23 '22 11:09

xims


Your host is simply the web address to your Heroku app. For instance, if your Heroku app is named peerjsapp, then host would be 'peerjsapp.herokuapp.com'. You can find the name of your app on your Heroku dashboard. The port is usually 9000, but can be 443 if you're using HTTPS (make sure to also pass in secure:true if you're using HTTPS). You don't need to include the path unless you've changed it; if you're running the default server config, leaving out the path on your client will automatically connect. Finally, since you're hosting your own server, you don't need an ID.

like image 31
mt_xing Avatar answered Sep 22 '22 11:09

mt_xing