Giter Site home page Giter Site logo

Bidirectional Streams? about peerjs HOT 16 CLOSED

peers avatar peers commented on May 16, 2024
Bidirectional Streams?

from peerjs.

Comments (16)

ericz avatar ericz commented on May 16, 2024

That should definitely not be happening. Do you see the same behavior on http://cdn.peerjs.com/demo/chat.html?

from peerjs.

simonlast avatar simonlast commented on May 16, 2024

Yeah, It's the same for me. Here are the exact steps I'm taking:

Peer 1: peer.connect('Peer 2 ID');
Peer 1: peer.connections['Peer 2 ID'].send('hello'); //works properly
Peer 2: peer.connections['Peer 1 ID'].send('hello'); //doesn't do anything

from peerjs.

michelle avatar michelle commented on May 16, 2024

I've seen this before--it happens when one peer does not receive all of the ice candidates of the other. But as Eric said, this should not be happening anymore.

Could you paste the logs from the console on both peers when trying to connect on http://cdn.peerjs.com/demo/chat.html?

from peerjs.

simonlast avatar simonlast commented on May 16, 2024

Sure!

Peer 1:

PeerJS:  Socket open peer.js:751
> peer.connect('75avj2e30mpzm2t9');
PeerJS:  Creating RTCPeerConnection peer.js:751
PeerJS:  Listening for ICE candidates peer.js:751
PeerJS:  Listening for `negotiationneeded` peer.js:751
PeerJS:  Creating data channel peer.js:751
DataConnection {_events: Object, _options: Object, open: false, id: "fwdh6ly7pvmzehfr", peer: "75avj2e30mpzm2t9"…}
PeerJS:  `negotiationneeded` triggered peer.js:751
PeerJS:  Created offer peer.js:751
PeerJS:  Set localDescription to offer peer.js:751
PeerJS:  Received ICE candidates peer.js:751
PeerJS:  Set remoteDescription: ANSWER peer.js:751
PeerJS:  Added ice candidate peer.js:751
PeerJS:  Data channel connection success peer.js:751
> peer.connections['75avj2e30mpzm2t9'].send('hello'); //this works
    undefined

Peer 2:

PeerJS:  Socket open peer.js:751
PeerJS:  Creating RTCPeerConnection peer.js:751
PeerJS:  Listening for ICE candidates peer.js:751
PeerJS:  Listening for `negotiationneeded` peer.js:751
PeerJS:  Listening for data channel peer.js:751
PeerJS:  Added ice candidate peer.js:751
PeerJS:  Received data channel peer.js:751
PeerJS:  Set remoteDescription: OFFER peer.js:751
PeerJS:  Created answer peer.js:751
PeerJS:  Set localDescription to answer peer.js:751
PeerJS:  Received ICE candidates peer.js:751
PeerJS:  Added ice candidate peer.js:751
PeerJS:  Received ICE candidates peer.js:751
PeerJS:  Data channel connection success peer.js:751
> peer.connections
    Object {fwdh6ly7pvmzehfr: DataConnection}
> peer.connections['fwdh6ly7pvmzehfr'].send('hello'); //this does nothing
    undefined

from peerjs.

michelle avatar michelle commented on May 16, 2024

Awesome, thanks :). I will see if I can reproduce it. You're on latest Canary, using two tabs?

from peerjs.

simonlast avatar simonlast commented on May 16, 2024

Yup!

On Thu, Feb 14, 2013 at 4:26 PM, Michelle Bu [email protected]
wrote:

I will see if I can reproduce it. You're on latest Canary, using two tabs?

Reply to this email directly or view it on GitHub:
#9 (comment)

from peerjs.

whytheplatypus avatar whytheplatypus commented on May 16, 2024

I wound up just treating it like readonly writeonly streams and opening a connection back on a "connection" event
It's up and running here

in some ways this might be considered a feature rather than a bug? Although I can't think of a good use case off the top of my head.

from peerjs.

michelle avatar michelle commented on May 16, 2024

That's really weird. I still haven't been able to reproduce this single directional connection bug. Any more details on OS, exact Chrome build, etc?

The fact that the 'Data channel connection success' message logs means that the DataChannel is in the open state, at which point the transfer of data is no longer in PeerJS's control. That being said, you guys should try out some of the other demos, like 'http://sharefest.peer5.com/' that DON'T use PeerJS to see if you have similar issues.

Edit: Actually there's very few 2-way DataChannel demos that would actually test this kind of functionality, but it seems that similar one-way problems are happening with WebRTC media streams as well, so we'll just keep up to date with commit logs and see what happens.

from peerjs.

michelle avatar michelle commented on May 16, 2024

@whytheplatypus We just tried it and it works! Cool stuff. I also cloned it myself and took out the extra connection when a 'connection' event is fired. This also worked for me, so this is still a pretty weird bug.

from peerjs.

whytheplatypus avatar whytheplatypus commented on May 16, 2024

Little more info on the bug:

Uncaught Error: InvalidStateError: DOM Exception 11 peer.js:1315
(anonymous function) peer.js:1315
fr.onload peer.js:795

it looks like this has something to do with self._dc.send(str); but I haven't dug deep enough to know what yet.
Oh this is also with running a local PeerServer.. no idea if that makes a difference.

glad you liked the chat thing :P this stuff is so much fun to work with

from peerjs.

michelle avatar michelle commented on May 16, 2024

@whytheplatypus Does the 'open' event on that connection object ever fire? What is connection._dc.readyState? Using a local PeerServer should not matter. I actually just ran some connection speed benchmarks today using the latest version of the server on npm and the connections seemed to be just fine.

It seems to be happening to only a handful of people; really wish I could repro.

from peerjs.

simonlast avatar simonlast commented on May 16, 2024

Could it be due to firewalls?

from peerjs.

whytheplatypus avatar whytheplatypus commented on May 16, 2024

Alright well it looks like there's no bug after all.. at least for me.. I just wasn't listening for the data event in the right place. There's no new 'connection' event on the peer that called peer.connect(id) so it wasn't listening for any 'data' events.

adding

conn.on('data', function(data){
  //code
});

after

var conn = peer.connect(id);

was all that I needed...

from peerjs.

michelle avatar michelle commented on May 16, 2024

Glad to hear it :)

from peerjs.

michelle avatar michelle commented on May 16, 2024

I believe this is just due to firewalls and is not a bug in PeerJS, so I'm closing this for now.

from peerjs.

pfifo avatar pfifo commented on May 16, 2024

I see this is a really old issue, however this problem is occuring for me on the official chat demo http://cdn.peerjs.com/demo/chat.html

Chromium
Version 58.0.3029.110 Built on Ubuntu , running on Ubuntu 16.04 (64-bit)

I have a standard NAT setup, and can get bidirectional data working just fine with WebRTC itself.

Edit:
I was just thinking this could be an issue with Peer 1 sending to my local private IP address, and peer 2 trying to send to my public IP address that has not been hole punched yet. Just a thought.

from peerjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.