meetecho / janus-gateway

Janus WebRTC Server
https://janus.conf.meetecho.com
GNU General Public License v3.0
7.99k stars 2.45k forks source link

ICE disconnects / fails when connecting 3 users to mvideoroomtest with data: true #1556

Closed qmohammed93 closed 5 years ago

qmohammed93 commented 5 years ago

I am testing mvideoroomtest in PR #1459 (Unified Plan branch), using Firefox browser.

I set data: true where the comments recommended it for data channel use. I have set up ondataopen and ondata callbacks (for both the Janus.init and subscribeTo()). I've set data: true in three locations, two within the media object in publishOwnFeed() and remoteFeed.createAnswer() and a final one in the publish variable within the sfutest.createOffer (I also tried removing it from this to see if it would change anything, no difference) .

Everything works completely fine after adding two people to the room. Data channels can be sent and received by both peers.

However once a third person joins the room, then one user will become disconnected and I receive the following messages in the JS console:

ICE state changed to disconnected mvideoroomtest.js:130:10 ICE state changed to failed mvideoroomtest.js:130:10 ICE failed, add a TURN server and see about:webrtc for more details

The janus.log looks like this at that time:

[ERR] [ice.c:janus_handle_setup_remote_candidates:2987] [8177548808392846] Failed to set remote candidates :-( (added 1, expected 2) [8177548808392846] The DTLS handshake has been completed [janus.plugin.videoroom-0x7f052c082ef0] WebRTC media is now available [WARN] [5072814817164774] No stream, queueing this trickle as it got here before the SDP... [WARN] [5072814817164774] No stream, queueing this trickle as it got here before the SDP...

Note: All peers are in the same office, on the same network, controlled by me.

Most often it seems it's the second user that joined which ends up with the ICE disconnected messages. This user's video is frozen on the other peers, and he cannot send data channel messages - however, he can receive data channel messages from the other peers.

lminiero commented 5 years ago

I haven't tested datachannels in that configuration yet, so can't confirm it's an issue. I'm away for the IETF this week, so it may be a while before I can investigate.

That said, it looks like an ICE failure, so you may want to check the Admin API for the reason why it fails.

lminiero commented 5 years ago

Mh, just replicated your issue, and it is indeed as you said: in my case the first user that joined had his publisher ICE state change for some reason, which makes no sense since it was not THAT PeerConnection that was being updated or established. As a result, the other two participants got no video from that user. I'll have a look to see what's going wrong, and to see if it's a client thing or a server thing.

lminiero commented 5 years ago

Ok, found out the issue: it was a missing unlock when updating a subscription, in particular when trying to add a second datachannel (that we prevent when we already have one). The relevant fix is here: https://github.com/meetecho/janus-gateway/pull/1459/commits/a0240a17afa7a1a6377a48ad6630b5d2b54f6ed7