mafintosh / webrtc-swarm

Create a swarm of p2p connections using webrtc and a signalhub
MIT License
380 stars 60 forks source link

doesn't fully connect > 2 peers #18

Closed mreinstein closed 7 years ago

mreinstein commented 7 years ago

my script:

var swarm = require('webrtc-swarm')
var signalhub = require('signalhub')

var hub = signalhub('swarm-example', ['http://localhost:8000'])

var sw = swarm(hub)

sw.on('peer', function (peer, id) {
  console.log('connected to a new peer:', id)
  console.log('total peers:', sw.peers.length)
})

sw.on('disconnect', function (peer, id) {
  console.log('disconnected from a peer:', id)
  console.log('total peers:', sw.peers.length)
})

this is browserified and served up in latest chrome. I also have signalhub running locally with the command:

signalhub listen -p 8000

I open 3 browser windows to the test script from above. the first 2 connect. The 3rd doesn't.

lukeburns commented 7 years ago

Just added a test to check for this, but it's passing fine. That said, I am having exactly the same issue in browser (Chrome 52).

lukeburns commented 7 years ago

I cannot connect to more than two local peers, but I'm having no trouble connecting to more than two remote peers.

perguth commented 7 years ago

Yes, that happens. I can't tell you why but just open your third and fourth tab using the browsers incognito mode. Then it will work. Please confirm.

mreinstein commented 7 years ago

@pguth I've confirmed that is the case for me (chrome 53.) Opening tabs in incognito mode solves the problem. It would probably be good to leave this issue open since it's technically a bug. Not sure if it's in signalhub or webrtc-swarm.

I'll send a PR with a note in the README about this current limitation.

perguth commented 7 years ago

@mreinstein Thanks 🎆! But I close since it's outside the scope of webrtc-swarm (technically and practically). For the purpose of bouncing information between tabs maybe give page-bus a try.

I'll send a PR with a note in the README about this current limitation.

💯

mreinstein commented 7 years ago

@pguth if we aren't sure what is causing this limitation, how do we know that this isn't something caused by the way webrtc-swarm interacts with the underlying signalhub instance? We don't know if this is a bug in this module, or upstream. Closing the issue hides it.

For the purpose of bouncing information between tabs maybe give page-bus a try.

cool module! 👍

perguth commented 7 years ago

I strongly suspect this to be a browser limitation. I find the interaction between those two modules quite clear. But if you find out more please let us know. :eyes:

mreinstein commented 7 years ago

@pguth I just tried signalhub with 3 local connections and they're able to communicate with each other, without having to resort to incognito mode. That leads me to think the problem is somewhere in this module, or in simple-peer.

perguth commented 7 years ago

I will certainly stay subscribed :)

G-Ray commented 5 years ago

Any update on this ?

mckeown12 commented 4 years ago

Any update on this?

mreinstein commented 4 years ago

I haven't taken time to explore this, and it's been too long; I'm no longer familiar with the internals of these webrtc modules.

I still suspect the limitation is somewhere in webrtc-swarm or signalhub; I don't know of any webrtc limitation in the spec that prevents having more than 2 connections per browser/host.