1

I am using nodejs for video call application where if user A and user B are in different networks then :- iceConnectionState: "checking" iceGatheringState: "gathering"

and streaming not coming of remote user but its works when both are in same network /wifi

iceConnectionState: "checking" iceGatheringState: "gathering"

iceConnectionState: "completed"

Nitish Kumar
  • 13
  • 1
  • 5

1 Answers1

0

Do you have set the ice servers, especially the turn server (or at least the stun server)? You have to pass a configuration object to the RTCPeerConnection-Constructor, which contains the field iceServers: [{urls: 'stun:some.stun.server.address},...] Since it sounds to me like the ice gathering process checks the generated candidate addresses:

  1. It checks the local address (like 127.0.0.1) but since it is not running on the same computer, it fails.
  2. It checks the OS IP (something like 192.168.178.13, for example) and this will work, if the 2 computers are in the same network, but on different networks, those local IP's do not help...
  3. It makes a STUN request, asking an external server, what IP this request comes from. The Adress is different, since NAT does its job. Then it will try to connect with this reflexive address. For many NATs this will still not work, since incoming requests without previous outgoing connection to the IP will be forbidden
  4. It makes a TURN request, and routes the entire conversation through a relay server. This should work in nearly any case

If you did not set STUN and TURN servers in your config, step 3 and for won't be tried, because there will be no reflexive address from the stun server and no turn server relay address. Therefore, the ice gathering may end at step 2 (and be complete) but there will be no connection, since 1. and 2. will fail on different networks

nasskalte.juni
  • 433
  • 3
  • 14
  • I am using STUN and TURN server . However unable to get remote stream. iceServers = [{ 'urls': [ 'turn:webrtcweb.com:7788', 'stun:webrtcweb.com:7788', ], 'username': 'muazkh', 'credential': 'muazkh' }]; – Nitish Kumar Oct 17 '19 at 18:00
  • @NitishKumar ok, this makes things more complicated. How confident are you that the listed servers work? While the listed domain reacts to ping, I made a test against the turn server with [this snippet](https://stackoverflow.com/a/34033938/5025161) on stack overflow and [this webrtc ice test](https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/) and it said that the turn server does not work (maybe a configuration problem?). Try your config with the public stun server stun.l.google.com:19302 or any one of [these](https://gist.github.com/zziuni/3741933). – nasskalte.juni Oct 18 '19 at 21:46
  • Now i am using own configure COTURN(tested :- https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/) server and google's stun server. However i am on same stage . like:- connectionState: "connecting" and iceConnectionState: "checking" that i am getting in console. Help me to figure out please. where i am doing wrong – Nitish Kumar Oct 20 '19 at 19:03
  • Ok, this is strange, I was sure it was something like missing reflexive (STUN) and relay (TURN) addresses. Can you try to log the received ice candidates before you add them to your peer connection (right before you call yourRTCPeerConnection.addIceCandidate)? Check if you really receive candidates of the type relay and host. You can identify them on their candidate value, a string which will contain the part "typ srflx" and "typ relay". – nasskalte.juni Oct 20 '19 at 23:31
  • While testing i am getting error in turn server:- transport=tcp returned an error with code=701: . I used to setup this link :-https://www.netways.de/blog/2017/08/16/setting-up-a-turn-server-for-nextcloud-video-calls/ – Nitish Kumar Oct 21 '19 at 18:27
  • The tutorial in the link looks fine. The turn server is not running in a network behind NAT, I assume? Also, the firewall has the following ports open?: 1. [3478](https://tools.ietf.org/html/rfc5766#section-4) (standard inbound turn port) 2. [49152–65535](https://tools.ietf.org/html/rfc5766#section-6.2) (allocated ports for outbound turn connections) And the test page did not show any non-host candidates? – nasskalte.juni Oct 21 '19 at 19:52
  • I appreciate your kind co-operation.However i am unable to fix issue of turn server . I have done everything step by step. Would you please recommend any tutorial to setup TRUN/coTURN server. – Nitish Kumar Oct 22 '19 at 18:26
  • Ok, I wish you good luck and hope that it will work. There are not many good sources regarding COTURN installation and administration. The tutorial you used is, like already said, quite ok. Alternatively, have a look at [this](https://docs.bigbluebutton.org/2.2/setup-turn-server.html) and if you get it running, have also a look at [dynamic turn credentials](https://stackoverflow.com/a/35767224/5025161). You may already know it, but for debugging purposes, chrome offers an overview over webrtc connections via chrome://webrtc-internals – nasskalte.juni Oct 23 '19 at 12:30