simplewebrtc / SimpleWebRTC

Simplest WebRTC ever
Other
4.64k stars 1.2k forks source link

Connectivity Issues on mobile networks (3g/4g/LTE, etc) #732

Closed cmar0ck closed 5 years ago

cmar0ck commented 5 years ago

Hi all,

I'm facing connectivity issues when using SimpleWebRTC from a mobile network like 3g/4g/LTE etc. (Corresponding error messages are: "Connecting to peer" / "Connection failed"). As from what I've read I need to setup my own singaling (STUN/TURN?) server to circumvent these issues but I'm not that familiar with running (and deploying) own node.js servers (yet), so I'd prefer an easier method if possible.

Are there any free webservices I could use alternatively / which ones would you recommend the most? Could I run node.js on a Raspberry Pi for this purpose?

I didn't find any detailed enough resources on the web how to make this work (for e.g. like talky.io does it), if you could point me into the right direction I'd highly appreciate it.


Edit: I had a look at Temasys' Skylink, which seems to be able to do the trick, unfortunately it's not free... EasyRTC doesn't seem to provide the signaling part, at least their demos didn't work for me from mobile networks.... Not sure if and how Pusher could be used for this purpose, going to check this now.

fippo commented 5 years ago

See https://testrtc.com/webrtc-api-trace/ (in particular example 1) for how to determine why the connection fails.

Next you'll want to read https://bloggeek.me/google-free-turn-server/ on why there is no "free" turn server. You will have to run your own (which costs money) or pay someone.

cmar0ck commented 5 years ago

Thanks for the links. So I set up my own turn server (using coturn) now but can't get SimpleWebRTC to use it. I tried editing v3-latest.js and replacing the default Google stun server with my turn server, but that didn't work for some reason... How can I do it (is it even possible without using signalmaster)?

fippo commented 5 years ago

signalmaster will override your turn servers. Run your own.

cmar0ck commented 5 years ago

That's exactly what I'm trying. How can I use my own turn server with SimpleWebRTC?

fippo commented 5 years ago

run your own signalmaster.

cmar0ck commented 5 years ago

Not sure if I get this right.... I have to use signalmaster in order to use my own turn servers with SimpleWebRTC?

fippo commented 5 years ago

yes. In general you should not use the sandbox server, see https://github.com/andyet/SimpleWebRTC/blob/c6c724110b4496200791b7e603f3014ca0bdc533/notsosimple.md#do-not-use-the-default-sandbox-signaling-server-in-production

cmar0ck commented 5 years ago

I see... I thought I could enter the credentials of my turn server in latest-v3.js just like that:

function WebRTC(opts) { var self = this; var options = opts || {}; var config = this.config = { debug: false, // makes the entire PC config overridable peerConnectionConfig: { iceServers: [{'urls': 'turn:myturnserverip:1234'}] }, ...

fippo commented 5 years ago

you can not. because hardcoding turn credentials in a js file is a very bad idea.

cmar0ck commented 5 years ago

very true.

cmar0ck commented 5 years ago

Okay, after hours of trying (and failing) to get the signalmaster to run I'd like to put my turn credentials in a js file, although I know that's a bad idea for numerous reasons. Which parts of SimpleWebRTC would I have to uncomment in order to 'inject' my own turn credentials?

JakeTrock commented 5 years ago

I use socket.io, and believe your initilisation should look something like this: var webrtc = new SimpleWebRTC({ remoteVideosEl: 'remotesVideos', localVideoEl: 'localVideo', autoRequestMedia: true, detectSpeakingEvents: true, autoAdjustMic: false, url: 'https://www.example.com/', socketio: {path: "/signal/socket.io"}, media: {video: false,audio: true}, debug: false }); the socketio path should be where you are running socketio, but you could delete it if you wish to use a different signalling server