1

Here is client side code: http://hostcode.sourceforge.net/view/2911

Here is server side code: http://hostcode.sourceforge.net/view/2912

So what happens is, I have two buttons. I am new to webrtc, so I am just testing this out with buttons for now.

I open one window and go to localhost. I click accept camera, and see myself in the camera. Then, on the first window, I am supposed to click on connect. I don't click on the other button!

I open another window and go to localhost. I click accept camera, see myself, and then I click first on connect, and THEN on create offer button. These two windows get connected, BUT it generates like 8-15 ice candidates... And I have them logging on the console. So many ice candidates.... why? Is it a list of all the people on my wifi network? Or what? Where it says "Ok so this is ice candidate event, I guess:" and then it lists the ice candidate.... It writes that like 14 times in console.log, just when those two windows connect! It doesn't make any sense...

Hellothere
  • 233
  • 3
  • 15
  • 1
    How many would you expect? Do you know what the ICE protocol does and what ICE candidates are? – deceze Mar 25 '15 at 21:04
  • 1
    It also sends out like a whole bunch of offers. I thought ice candidates were people who have opened a window and connected. Why does it send out so many offers? It still connects the two windows, but the whole "it sending out so many offers" thing stops me from being able to have multiple peer to peer connections. – Hellothere Mar 25 '15 at 21:08
  • typically that happens when it takes a while for a client to connect. you can throttle them so that there's not so many before one is accepted. – dandavis Mar 25 '15 at 21:12
  • 1
    http://stackoverflow.com/questions/21069983/what-are-ice-candidates-and-how-do-the-peer-connection-choose-between-them – loganfsmyth Mar 25 '15 at 21:16
  • Also read: https://stackoverflow.com/questions/61735730/what-about-to-remove-listener-once-we-signal-the-ice-candidate-to-other-peer – Bhojendra Rauniyar May 11 '20 at 17:53

1 Answers1

3

I thought ice candidates were people who have opened a window

Nope, that's where you're wrong. The ICE protocol is trying to establish a direct network connection between the two peers. This is a hard problem. There are many problems in regular networking topology to work around and many possible routes a direct connection could take. The ICE protocol uses a third party server (as in, somebody other than the two clients you're trying to connect) to probe possible network paths between both peers. That's what ICE candidates are. They're one suggestion how a connection may be established. The three parties keep probing and testing different possibilities until all are exhausted and/or a good direct connection has been established.

deceze
  • 510,633
  • 85
  • 743
  • 889
  • 1
    How can you tell which specific ice candidate, or connection, is being used? – Hellothere Mar 25 '15 at 21:19
  • I'm not sure. It's probably some property on the `RTCPeerConnection` object you can read. Why do you care? It's an implementation detail of the underlying network layer which is pretty much irrelevant to you unless you're a network engineer. – deceze Mar 25 '15 at 21:21
  • Alright. Well, I thought that the ice candidates were what was causing my problem. My problem is, is that when I try to put the two people into a room it doesn't connect them. So when on my server code I write socket.join('someroom') and then in stead of the broadcast, I write socket.to('someroom').emit('sessiondesc', sessiondesc'); it doesn't join the two people at all. – Hellothere Mar 25 '15 at 21:28