Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set up peer to peer connection using peerjs #251

Open
deepikabirthare opened this issue Jun 20, 2021 · 2 comments
Open

Unable to set up peer to peer connection using peerjs #251

deepikabirthare opened this issue Jun 20, 2021 · 2 comments
Labels

Comments

@deepikabirthare
Copy link

deepikabirthare commented Jun 20, 2021

I'm having an issue:

  • I want to setup peer to peer connection combining it with express
  • Here is my server side code :
  • const express = require('express') const app = express(); const server = require('http').Server(app); server.listen(process.env.PORT||9000); const { ExpressPeerServer } = require("peer"); const peerServer = ExpressPeerServer(server, { debug: true, }); app.use("/peerjs", peerServer);

And my client side code:

var myPeer = new Peer(undefined, { path: "/peerjs", host: "/", port: "9000", });

And I include this library in my html document

<script src="https://unpkg.com/[email protected]/dist/peerjs.min.js"></script>

But when I am running my app on local host I am getting error
image

I read the documentation it says

path : '/myapp'

I am confused what myapp is in the path

Does it mean I can create peerjs server and deploy it and then use it any time for peer to peer connection in any other app?

If I can do so it is the best option but documentation seems confusing.

I need urgent help and want to know about

  1. How can I make peer to peer connection in any app?
  2. Can I deploy only peerjs server on say heroku and then use it for establishing connection in any other app?
  3. What is '/myapp' ?
  4. How can I make peer to peer connection on local host ?
  5. Why am I getting this error and what is wrong with my current code?
@spine001
Copy link

spine001 commented Jul 21, 2021

Check the answer to this question here and the link in the answer to github where a complete working example is placed. You may solve all your problems. At least the ws.... error goes away. You may want to only use the http part and just ignore the https server built into the example. Change ports accordingly.

Please watch out for the reverse order in the example of calling the peer.on('call',.... event handler first and waiting for the stream promise to return inside the 'call' event handler. This is the only way you can make sure that you won't receive a call event before you have set up your handler for that event. Most of the examples and tutorials have this bug in them

@SHUBHAMspy
Copy link

I'm having an issue:

  • I want to setup peer to peer connection combining it with express
  • Here is my server side code :
  • const express = require('express') const app = express(); const server = require('http').Server(app); server.listen(process.env.PORT||9000); const { ExpressPeerServer } = require("peer"); const peerServer = ExpressPeerServer(server, { debug: true, }); app.use("/peerjs", peerServer);

And my client side code:

var myPeer = new Peer(undefined, { path: "/peerjs", host: "/", port: "9000", });

And I include this library in my html document

<script src="https://unpkg.com/[email protected]/dist/peerjs.min.js"></script>

But when I am running my app on local host I am getting error image

I read the documentation it says

path : '/myapp'

I am confused what myapp is in the path

Does it mean I can create peerjs server and deploy it and then use it any time for peer to peer connection in any other app?

If I can do so it is the best option but documentation seems confusing.

I need urgent help and want to know about

  1. How can I make peer to peer connection in any app?
  2. Can I deploy only peerjs server on say heroku and then use it for establishing connection in any other app?
  3. What is '/myapp' ?
  4. How can I make peer to peer connection on local host ?
  5. Why am I getting this error and what is wrong with my current code?

I am also having similar error any solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants