EricssonResearch / openwebrtc

A cross-platform WebRTC client framework based on GStreamer
http://www.openwebrtc.org
BSD 2-Clause "Simplified" License
1.8k stars 537 forks source link

OpenWebRTC appears to fail all connections if given a TURN server #85

Closed dbkr closed 9 years ago

dbkr commented 9 years ago

If a working TURN server is supplied instead of just an stun server (or the empty array), OpenWebRTC fails to establish calls for me.

Test environment: Safari with OpenWebRTC extension calling Chrome (with Chrome native WebRTC). Both have a working TURN server configured in the iceservers parameter. Both browsers are on the same LAN and can communicate directly without the use of a STUN or TURN server.

Actual behaviour: Chrome fires events for the remote streams and its ICE state transitions to connecting. Safari never fires onaddstream. The two parties appear to be exchanging STUN and even get to DTLS negotiation on at least one channel.

Either replacing the TURN server with a STUN server or supplying the empty array as the iceservers parameter causes calls to connect successfully.

dbkr commented 9 years ago

I should add, the TURN server in question is a coturn.

Also, logs with libnice debug turned on are at https://gist.github.com/dbkr/51134314ed483b9b9f74#file-gistfile1-txt

dbkr commented 9 years ago

It's only affected by adding a turn url with transport=udp. Adding A turn URI with transport=tcp or turns transport=tcp does not trigger the bug (presumably because they're just not supported?)

stefanalund commented 9 years ago

@alessandrod do you know if this is a bug in libnice?

superdump commented 9 years ago

Not sure if it is a bug or just that only TURN TCP is supported. I have a feeling it is the latter but would need to check.

dbkr commented 9 years ago

The latest version of our app with OpenWebRTC fixes is now live at http://matrix.org/beta/

I have specifically not included a workaround for this issue, so you can see this bug in action by placing a call there.

stefanalund commented 9 years ago

@alessandrod or @sdroege do you know?

ocrete commented 9 years ago

libnice definitely supports TURN UDP. It supports most of rfc 5466 TURN except for the TLS part. But we don't actually support real TURN TCP (RFC 6062, creating TCP-like connections), but that part is not used by WebRTC.

I've been using libnice successfully with turnserver.org, the google TURN server and rfc5466-turn-server, of which coturn is a derivative. So in theory, coturn should "just work", but I haven't tested it. I've also seen reports of people having issues with libnice and coturn. So unless you feel like debugging libnice, I'd recommend another TURN server.

dbkr commented 9 years ago

Yeah, it's certainly trying to talk TURN UDP to the coturn. I've just verified again and got the same though: if I specify the UDP TURN URI, OpenWebRTC never connects (even though they don't need TURN. If I remove it, it connects fine (ie. not using a TURN server). It also works if I change the password to be invalid so the fact that it connects to the coturn somehow breaks its ability to connect a call.

superdump commented 9 years ago

I expect @pererikb or @ocrete would know better but perhaps something is going amiss there and the gathering done signal is never fired. In which case, perhaps using trickle ICE could still work. Can we confirm that @pererikb?

stefanalund commented 9 years ago

@pererikb did this latest commit help with this specific issue?

https://github.com/EricssonResearch/openwebrtc/commit/605fbcdc734444a936dde73ddc19b300f59c7503

pererikb commented 9 years ago

No. I am still investigating this issue.

pererikb commented 9 years ago

The problem is that the socket replacement here http://cgit.freedesktop.org/libnice/libnice/tree/agent/agent.c#n3287 is not restricted to ICE-TCP and UDP-TURN-OVER-TCP sockets.

kakaroto commented 9 years ago

Hopefully this fixes it : http://cgit.freedesktop.org/libnice/libnice/commit/agent/agent.c?id=e4b8707d4ada89d09d9513775f165bd6c1481e1e

Let me know if it makes things better for you. Thanks.

sdroege commented 9 years ago

@pererikb does this help? We're also including this change in the cerbero build then

ocrete commented 9 years ago

If this fixes it, I'll make a new upstream release, we've accumulated a few bug fixes.

pererikb commented 9 years ago

Yes, this fixes the issue

dbkr commented 9 years ago

Just re-tested (sorry for the delay): I can confirm this does appear to fix the problem.

stefanalund commented 9 years ago

:+1:

kakaroto commented 9 years ago

Great. Thanks for the confirmation.

stefanalund commented 9 years ago

@kakaroto @ocrete let us know when there is a new release, thanks!

nirbheek commented 9 years ago

As an aside, since yesterday Cerbero includes a patch for using the latest code from git, so this isn't blocking us too much: https://github.com/nirbheek/cerbero/commit/478270572cdaa4c6dbdb9c7346c91db4266bf09a

ocrete commented 9 years ago

Released libnice 0.1.9 which should include all of the patches

superdump commented 9 years ago

And 0.1.10 as well I see. :) we will update. Thanks @ocrete

nirbheek commented 9 years ago

Cerbero has been updated to 0.1.10: https://github.com/nirbheek/cerbero/commit/bcf4d9e74cb0b76eccaaf7f0311838188a17c864

stefanalund commented 9 years ago

Me and @superdump just confirmed that it is now possible to run OpenWebRTC (in Safari) -> Chrome using Matrix. Closing this issue, thanks for all the debug support.